09-07-2011 10:50 AM
I have a Graphics object for one field and I override paint() and I do some additional paining.
After that I want to create a Bitmap but the problem is that the Graphics object isn't for the Bitmap class.
So how can I create a Bitmap object using the Graphics I have?
Solved! Go to Solution.
09-07-2011 11:40 AM
I have never found a way to do this.
Just to confirm the question, you have a paint method and in it you have painted onto your Graphics object. Now you want to make a copy of this painted region, on a separate Bitmap so that you can use it elsewhere.
In this circumstance, I have only two solutions
a) Paint onto a separate Bitmap first, and then paint the Bitmap onto the graphics object.
b) Display the Graphics on a screen and do a Screenshot.
Love to hear other options.
09-07-2011 11:46 AM
09-07-2011 12:10 PM - edited 09-07-2011 12:13 PM
Yeah, you can pass the new Graphics object into the paint of your Screen directly as long as you make the paint method public. If your Screen is already populated, then you should get the same results as what you would see on the display. The same works for any Manager or Field. Just be aware that the background of the new Graphics object starts out as white and not transparent.
09-07-2011 04:00 PM
Thanks for the suggestions everyone!
I don't know how to paint on a bitmap. If by paint you mean to override the paint() method this is not possible because BItmap is a final class and extending it is not allowed. Maybe I did not understand you correctly?
Making a screenshot also is not a solution for me because the bitmap is way bigger than the screen and I am using scrollable container to show it.
Also creating a new Graphics object for the bitmap is not a solution for me because as I mentioned my bitmap is big (1600x1200) and creating that big bitmap causes IllegalArgumentException to be thrown in the graphic's constructor.
09-07-2011 04:37 PM
09-08-2011 02:23 AM
09-08-2011 03:48 AM
09-08-2011 11:06 AM
09-09-2011 08:29 AM