Software Archive
Read-only legacy content
17061 Discussions

Error android.graphics.Canvas.throwIfRecycled when overlaying bitmaps

richard_s_5
Beginner
497 Views

Im trying to overlay images on a canvas using the following method:

private Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {

    bmOverlay = Bitmap.createBitmap(70, 70, Bitmap.Config.RGB_565);
    canvas = new Canvas(bmOverlay);
    canvas.drawBitmap(bmp1, 0, 0, null);  //line 179
    canvas.drawBitmap(bmp2, 0, 0, null);
    return bmOverlay;           
}
However, my app keeps crashing and the log reads:

java.lang.NullPointerException at android.graphics.Canvas.throwIfRecycled(Canvas.java:954) at android.graphics.Canvas.drawBitmap(Canvas.java:980) at com.MyApp.overlay(MyApp.java:179)

Can anyone help?

0 Kudos
0 Replies
Reply