Getting snapshot produces always same value
I have this piece of code:
byte[] snap = ((VideoControl) player).getSnapshot("e开发者_运维技巧ncoding=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
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
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.
Are you sure getSnapshot() returns a VideoControl? Double check that.
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.
精彩评论