Bitmap won't draw

All your problems with Audio, Video and Images.

Bitmap won't draw

Postby SolidSora » Sun Feb 20, 2011 7:14 pm

I'm trying to draw a bitmap from the drawable folder but it won't draw, it causes my program to crash.

Code: Select all
package org.mydemo;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;

public class MyDemo extends Activity {
    /** Called when the activity is first created. */
   
    /***********************************
     *** Declaring variables here *****
     **********************************/
    //Context
   private Context gameContext;
   
   //Bitmaps
    private Bitmap background;
   
    //Paints
    private Paint bitmapPaint = new Paint();
   
    //private Canvas canvas;
   
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       //loadBackground();
        loadBackground();
    }
   
    public void loadBackground(){
       background = BitmapFactory.decodeResource(getResources(),R.drawable.background;
    }
   
    public void drawScreen(Canvas c){
       
       c.drawBitmap(background,0,0,bitmapPaint);
    }
}
SolidSora
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Oct 12, 2010 12:56 am

Top

Re: Bitmap won't draw

Postby Eimatsu » Tue Mar 01, 2011 3:39 pm

You should try to debug & catch the exceptions that it throws.
I think you get crash because of Out of Memory of Davik.
Try to sample down you bitmap.
Eimatsu
Freshman
Freshman
 
Posts: 2
Joined: Thu Nov 05, 2009 5:40 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 9 guests