Results 1 to 4 of 4
Thread: Convert Byte [] to BufferedImage
- 04-27-2008, 02:53 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 2
- Rep Power
- 0
Convert Byte [] to BufferedImage
I was wondering if any can show me how to create a bufferedImage from a byte []. I saw an example on the forums here that converts a bufferedImage to a byte []. So I thought someone might know. Thanks
The following was the code I found
Java Code:private byte[] image_byte_data(BufferedImage image) { WritableRaster raster = image.getRaster(); DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer(); return buffer.getData(); }
- 04-28-2008, 10:41 AM #2
- 04-28-2008, 05:06 PM #3
Member
- Join Date
- Apr 2008
- Posts
- 2
- Rep Power
- 0
Thanks for the response, however there is one particular part I'm stuck at. Is there a way to convert a byte [] to an bufferedimage without knowing the original height of the Image. For example, you take a bufferedimage convert it to byte [], then you store it into a database. Some point later you come back and just want to reconstruct the image using the byte array.
So my question would be, before I convert a bufferedimage to a byte [] should I also save the length and width of the image into the database so that I can reconstruct the image back up? The reason I'm asking this is because the images are all of different size.
- 04-28-2008, 05:54 PM #4
Similar Threads
-
Byte Values
By javaplus in forum New To JavaReplies: 1Last Post: 06-23-2008, 12:08 AM -
using Byte arrays
By mew in forum New To JavaReplies: 2Last Post: 01-30-2008, 03:54 AM -
BufferedImage to Byte
By Java Tip in forum Java TipReplies: 0Last Post: 01-22-2008, 08:17 PM -
int to byte
By ravian in forum New To JavaReplies: 1Last Post: 01-13-2008, 07:22 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks