views:

40

answers:

4

Hi, I have this piece of code:

byte[] snap = ((VideoControl) player).getSnapshot("encoding=jpeg");

, which gets a snapshot from the camera. Now, after a little processing it produces correct image. The weird part is, that when I debug this line of code, it always has the same value in the field even when the resulting image is different. Any ideas why?

Regards Trim

+1  A: 

Make sure the data you view is inside the array and not the memory address of the array (which doesn't need necessarily to change).

I hope this helps,

Good Luck

Drewen
Good answer! Wouldn't have thought of that one. Although why anybody would be looking at the memory address of a byte array such as that beats me.
funkybro
Interesting idea, but not this case. Thanks.
Trimack
A: 

Are you sure getSnapshot() returns a VideoControl? Double check that.

JavaRocky
I missed parentheses in the post. The VideoControl instance returns byte array ( http://java.sun.com/javame/reference/apis/jsr135/javax/microedition/media/control/VideoControl.html#getSnapshot(java.lang.String) )
Trimack
A: 

Perhaps some clarity is needed... what has the 'same value' in what 'field'?

Sounds like you take that byte array and turn it into an image. Then when you call getSnapshot again you get the same byte array but a different image?

Perhaps try getSnapshot(null).

Something like:

        byte[] data = null;

        try {
            data = video.getSnapshot(null);
        } catch (MediaException ex) {
            ex.printStackTrace();
        }

        if(data != null)
        {
            img = Image.createImage(data, 0, data.length);
        }

How are you 'debugging'? Emulator? On-device? What device?

The above code works for me on a K800i.

Wex
A: 

After extensive search I have found I was wrong and I do apologize for misguiding question. However, with the encoding=jpeg those arrays really differ only in a small part, but with another encodings they do differ extensively. Again, sorry for this question when I didn't verify it the hard way first.

Trimack