Skip to content Skip to sidebar Skip to footer

Canvas.drawbitmap Is Not Drawing Anything

I have overwritten onDragShadow for a DragShadowBuilder like so @Override public void onDrawShadow(Canvas canvas) { super.onDrawShadow(canvas); Bitmap bitmap =

Solution 1:

If you want to draw the bitmap as is (i.e. you want the whole thing), use:

canvas.drawBitmap(bitmap, null, source, null);

The 2nd parameter is for where you need to specify a subset of the bitmap to be drawn (it can be null if no subset is required). I expect there is a conflict within the method if you have src and dst (2nd and 3rd parameters) set to the same object.


Solution 2:

Checklist:

  1. Is the bitmap valid, i.e. not all transparent or the same as the background colour? You can view it easily in the Android studio debugger.

  2. Is your source rectangle (i.e. parameter 2, not 3 as is confusingly shown above) within the bounds of the bitmap? You're allowed to set this to null and that can be a good debugging step.

  3. Is your destination rectangle within the bounds of the canvas?

  4. Do you have a 4th parameter, 'paint', which has a low alpha value? Try 'paint.setAlpha(255)' or use 'null' for the 4th parameter.

  5. Do you see this message in your console? "OpenGLRenderer: Bitmap too large to be uploaded into a texture"? If so then see: "Bitmap too large to be uploaded into a texture"


Post a Comment for "Canvas.drawbitmap Is Not Drawing Anything"