I want to get byte array from Image Object.

I made the capture program with PC-Cam.

and I used the BufferToImage class, so I got images.

--

fgc = (FrameGrabbingControl)player.getControl("javax.media.control.FrameGrabbingControl");

buffer = fgc.grabFrame();

btoi = new BufferToImage((VideoFormat)buffer.getFormat());

image = btoi.createImage(buffer);

--

I want to send this images to another MIDlet program.

In MIDlet side, I have to know image's byte array to create Image.

--

in.read(btyeArray, 0, b.length);

img = Image.createImage(btyeArray, 0, btyeArray.length);

--

but There is no method to get byte array of image in Image class.

I try to make Image by using buffer's byte array.

but the result is... illegalArgument Exception.

How can I solve this problem?

[830 byte] By [viesa] at [2007-10-2 22:13:06]
# 1

I've just looked in the JDK API, and it is indeed a bit tricky.

An Image contains a Raster, a Raster contains a certain implementation of a Data Buffer. At this level you can get back a byte array by calling "getBankData()". See http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/DataBufferInt.html

I hope this helps.

Mongera at 2007-7-14 1:29:55 > top of Java-index,Java Essentials,Java Programming...