aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Pixels to PNG Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Pixels to PNG" Watch "Pixels to PNG" New topic
Author

Pixels to PNG

Ken Wilson
Greenhorn

Joined: Jan 19, 2001
Posts: 4
Can someone please point me in the right direction? If I have an array containing image data (pixels), how can I convert this to an graphic file (e.g. PNG or JPG)?
Thanks!
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Ken,
You have to know how the pixels are encoded into the file, i.e. the file format, plus if there are any headers, etc. Luckily, you don't (usually) have to write your own encoding functions... sun provides a JPEG encoder in the com.sun.image.codec.jpeg package (it comes with the JDK... look here to get info http://java.sun.com/products/jdk/1.2/docs/guide/2d/api-jpeg/overview-summary.html ), and I am sure someone has written a PNG encoder... look around on the net with a good search engine for java & PNG...
The JAI (Java Advanced Imaging) API may also provide what you need ( I found it while looking around Sun for Java and PNG ), as well as possibly the Java2D API... you can find (exhaustive) references to these if you go to Sun and type PNG into their site search.
HTH,
-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
wood burning stoves
 
subject: Pixels to PNG