How do I convert a Graphics object into an Image object?
I'm working within an application using JFrame, and what I want to do is create an Image, draw to the image using the methods of Graphics, and then display the image as an Icon.
If this isn't possible (which I doubt) then how would I work with Graphics objects outside of applets?
This will do the trick
You can create a BufferedImage (height, width & type), do a getGraphics to get the graphics context and draw into it:
Then, in the paintComponent(Graphics g) method of your image display JFrame (or JPanel) extension you draw the bufferedImage, just like an ordinary java.awt.Image.
BufferedImage memImg=new BufferedImage(applet.getWidth(), applet.getHeight(),BufferedImage.TYPE_INT_RGB);
Last edited by sjalle; 01-10-2006 at 02:51 AM.
Thanks sjalle It's a little rough around the edges but the image was created
By Ted Young in forum Database
Last Post: 08-07-2001, 04:53 PM
By Jaco de Villiers in forum XML
Last Post: 06-01-2001, 06:50 PM
By Nathan Moore in forum Web
Last Post: 05-09-2001, 02:15 PM
By Luis SantoTomas in forum XML
Last Post: 01-24-2001, 07:43 PM
By Greg Dirst in forum authorevents.appleman
Last Post: 04-10-2000, 03:56 PM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center