Results 1 to 4 of 4
- 12-15-2011, 06:57 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 30
- Rep Power
- 0
Going from byte[] to Jpeg on disk
Hi everyone,
I want to go from an array of bytes to a file written on disk. I found some ways to do this online, but they were all doing a somewhat roundabout way. (They set up a Graphics2d object to draw the image, pass it through a RenderedImage object, then use ImageIO.write class from the standard IO methods to get it on disk. Is this the best way to do this? Has anyone else found a good, efficient way to go from an array of bytes to a jpeg or gif on disk?
(Also, I should note that I'm on Java 6 and cannot currently upgrade...)
- 12-15-2011, 07:04 PM #2
Re: Going from byte[] to Jpeg on disk
There are several write() methods that take an array of bytes as source for what is written. Which classes have you tried?I want to go from an array of bytes to a file written on disk
Do you have code where you tried to do it that did not work? If so, can you post the code and describe the problems you are having with it?
- 12-15-2011, 09:19 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 30
- Rep Power
- 0
Re: Going from byte[] to Jpeg on disk
Thanks Norm. The code is actually quite convoluted, so I'll show my patched up solution. It all seems to be working now!
//Write the picture to disk.
BufferedOutputStream buff_out = new BufferedOutputStream(new FileOutputStream(file_for_cache));
buff_out.write(arr);
buff_out.close();
I was pretty amazed at how little lines of code were actually required!
- 12-15-2011, 09:27 PM #4
Similar Threads
-
convertir byte array "byte[]" to an image in j2me
By skon in forum New To JavaReplies: 1Last Post: 10-21-2011, 11:55 AM -
Read a bitmap byte by byte
By cbr400aero in forum Java 2DReplies: 2Last Post: 10-18-2010, 11:42 PM -
Streaming an image byte by byte (and similtaneosly rendering it on screen)
By ea25 in forum New To JavaReplies: 1Last Post: 04-21-2010, 02:28 AM -
Scaling a JPEG
By ScottVal in forum Advanced JavaReplies: 5Last Post: 03-21-2009, 08:47 PM -
urgent please.what do 4 repeating fields in byte array of jpeg specify?
By hemant in forum Java 2DReplies: 1Last Post: 07-04-2008, 05:39 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks