File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Converting Graphics to Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Converting Graphics to Image" Watch "Converting Graphics to Image" New topic
Author

Converting Graphics to Image

Deepan Devadasan
Ranch Hand

Joined: Jan 25, 2007
Posts: 226
Hi folks...

I have to add an Image to the Form...
Since the application should run on any phone with varying screen sizes, i want to add a background color to the image that is present...

Meaning i will create an image specifying the RGB using the display's width and height..

Then i am taking the Graphics from this image and draw my Image on the Graphics...

Up to this point there is no problem so far...

But now i dont have a way to convert the Graphics back to Image object so that it can be placed on the Form..


Can anyone give me some idea as to i could establish this..

Thanks in advance


Theepan Thevathasan
SCJP 1.4, SCWCD 1.4, SCMAD 1.0 SCBCD 1.3, MCP(.Net Frm 2.0 App Dev Fdn)
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
I sounds like you have already solved the problem. When you create a new image and call getGraphics(), the graphics object returned is directly related to the image and can be used to draw to the image.

If I understand the questions correctly, you code looks something like:



If so, you have done everything correctly a should see the desired output. Let me know if I have missed something.


Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting Graphics to Image
 
Similar Threads
Adding an image to form header
How to draw an image in negative form
Adding an image to form header
Drawing graphics on top of the camera view
placing an image into a panel