• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Converting Graphics to Image

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic