File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Converting an byte[] to an 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 » Java » Swing / AWT / SWT
Bookmark "Converting an byte[] to an image" Watch "Converting an byte[] to an image" New topic
Author

Converting an byte[] to an image

Zac Styris
Greenhorn

Joined: Nov 04, 2005
Posts: 14
Hi everyyone

I want to convet an byte[] which i've received from a mobile phone in to a image (jpg/png) after i receive it on the J2SE server end. Please some one help me with the method which i can just convert a byte[] in to a image n store it on the hard drive of the computer.

Thanks
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

javax.imageio.ImageIO can do what you need.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
What is the format of the data in the byte array? if it is already in JFIF (that's jpeg) or PNG format, just use java.io.* to write the data to a file. In other words, is there really a *need* to convert the data to an image?
[ January 27, 2006: Message edited by: Jeff Albertson ]

There is no emoticon for what I am feeling!
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
You can use JAI.



After you have the RenderedOp you can manipulate it how you want. For exampple,



Rashid Mayes
http://www.hostj2me.com/ - http://www.worlddeveloper.org/
Zac Styris
Greenhorn

Joined: Nov 04, 2005
Posts: 14
Thanks guys, Java.io just works fine n suits for wut i wanna do, thanks for helping again.

Rock on
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting an byte[] to an image
 
Similar Threads
Writing Buffered Image quality
how to remove unwanted pixels from image
Ho to display image getting from byte array in JSP ?
sending image file from applet to servlet
Commons codec Base64 problem