Re: How to create a byte[] from a MemoryImageSource?

From: ak (spam_at_imagero.com)
Date: 06/02/04


Date: Wed, 2 Jun 2004 21:45:14 +0200


> I need to output a byte[] buffer from a class that has access to a
> MemoryImageSource and/or a BufferedImage. I need to be able to
> somehow convert that to a byte array to pass on to another class.
> Does anyone have an elegant way to convert from a bufferedimage (or
> MIS) to a byte array?
MemoryImageSource takes byte or int array as argument
1) if it was byte array - nothing to convert
2) convert int array to byte array is easy work
If you have BufferedImage:
3) if you have BufferedImage than use getRGB() to get int array (see p. 2)

-- 
http://uio.dev.java.net
http://reader.imagero.com


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 use a byte array to create image
    ... image from a byte array is done by converting the bytes to an int[] and setting the data of the BufferedImage with setRGB. ... 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 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. ...
    (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)
  • 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. ... MIS) to a byte array? ...
    (comp.lang.java.programmer)