Re: how to use a byte array to create image



"Knute Johnson" <nospam@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:4862688e$0$4084$b9f67a60@xxxxxxxxxxxxxxxxxxxxx
jimgardener wrote:

[...]

If what you have is truly 'image data' in the Java sense then creating the image from a byte array is done by converting the bytes to an int[] and setting the data of the BufferedImage with setRGB(). From there use ImageIO to write out your TIFF file.

If the 'image data' is an array of bytes read from some file then I would have to know what sort of file to tell you how to proceed.

I too am interested in this. I have some JPEG files from which I need to create images suitable for transmission across a network and I note that BufferedImage does not implement Serializable. I can read the contents from the file as a byte array and transmit that array but how do I turn the array into some form of image to be displayed on a screen at the other end?

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
Qu0llSixFour@xxxxxxxxx
[Replace the "SixFour" with numbers to email me]

.



Relevant Pages

  • Re: how to get byte[] from an image
    ... A byte array or an int array? ... It's probably trivial to adapt it to return an int[] ... {@link BufferedImage}. ... internal DataBuffer banks isn't 1. ...
    (comp.lang.java.programmer)
  • how to use a byte array to create image
    ... i have a byte array that i contains image data.Can someone tell me how ... bufferedimage etc as below..but i don't know how to use my byte array ... private static BufferedImage mycreateImage(int width, ... int dataType = java.awt.image.DataBuffer.TYPE_USHORT; ...
    (comp.lang.java.programmer)
  • Re: How to create a byte[] from a MemoryImageSource?
    ... > MemoryImageSource and/or a BufferedImage. ... > somehow convert that to a byte array to pass on to another class. ... MemoryImageSource takes byte or int array as argument ...
    (comp.lang.java.programmer)
  • Re: byte[] to Image, HELP
    ... > I have a byte array, I get it from a Blob, such that if I write it ... > BufferedImage, from that buffer and I can't find a way to do it. ... > Cyril Mrazek ...
    (comp.lang.java.programmer)
  • Re: byte[] to Image
    ... setRGB(int, int, int) on a newly created BufferedImage for every pixel in ... the array. ...
    (comp.lang.java.programmer)