Hi everyone, I was wondering if it is possible to draw Canvas / Bitmap on the screen and use hardware acceleration or do I need to draw inside the onDraw() View method
For example, I draw on a screen bitmap by doing the following:
Bitmap.Config config = Bitmap.Config.ARGB_8888; Bitmap buffer = Bitmap.createBitmap(200, 200, config); Canvas canvas = new Canvas(buffer); Paint paint = new Paint(); paint.setColor(Color.RED); canvas.drawLine(0, 0, 100, 100, paint);
However, canvas.isHardwareAccelerated() returns false, and the drawing is sluggish compared to:
protected void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setColor(Color.RED); canvas.drawLine(0, 0, 100, 100, paint); }
where canvas.isHardwareAccelerated() returns true. Is there a way to draw in Bitmap, taking advantage of hardware acceleration? Or do I need to draw directly on the screen in the onDraw method?
Thanks for the help :) I know that in Java I can draw BufferedImage on the screen, and this will be hardware acceleration, but maybe this is not the same on the phone ...
source share