I have this code in a class that extends surface view and implements runnable I am able to use the class basically allows you to draw to the canvas using different colors and such. I'm trying to get a method that will allow me to save the image after it is drawn and this is the method. No matter what i do i just get a black image with nothing on it. Any ideas?
I have cache drawing enabled
Objective get a bitmap image from a custom SurfaceView I have exhausted options of looking at some other post on here and didn't find anything to work. Here is hoping that there is recently a new solution to this. Many thanks
public Bitmap getImage() {
Bitmap bitmap = Bitmap.createBitmap(this.getWidth(),
this.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
this.draw(canvas);
return bitmap;
}
this.getWidth()
andthis.getHeight()
to give? – AerometrysetWillNotDraw(false)
in your class constructor. – AerometryBitmapFactory.decodeResource()
. What if your code is working correctly, loading the Bitmap, but you are seeing a blank screen, because you have drawn nothing so far. Check this #3693560 – Aerometry