View Full Version : Output image
12-18-2011, 03:00 AM
How can I make a java applet that will, upon pressing the "save" button (I can make that), will save the visual output output as a PNG image file and (if possible/ideally) exclude the menu bar (the text input items, generate image button and save image button)? I want to make a puzzle (working on that. I want to give myself a chance before I ask for help) and save it as an image (or pdf, but too much stuff to do to make the encoder, and I can just tell them to use PDFCreator or something: why this will be a free software, besides the fact that I barely know what I'm doing)
12-19-2011, 05:50 PM
How can I display a buffered image on the screen, and how do you save it?
12-19-2011, 06:47 PM
You can use a back buffer to create the drawing space. Effectively, its identical to using the Graphic from a method like paint, except you store an instance of Image and Graphic in the object itself. Then when you paint, you simply force the use of the instance graphic instead, and draw it into the Graphics provided.
I'd typically use Graphics and Image to deal with a back buffer, but (I believe it will work anyway :/) you should be able to use a BufferedImage if you want. Writing is trivial, that is just an ImageIO.write call. Just google up Java Backbuffer tutorial, and you'll find a few techniques to do this.
If you use a Image though, you will need to convert it. I just found this method for converting which looks okay, but I have no idea of the age: http://www.exampledepot.com/egs/java.awt.image/image2buf.html
12-20-2011, 03:27 AM
I don't need to import an image; I need to generate one, which it appears from what you have said, I can do with this.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.