[android-developers] Re: converting RGB565 byte array to integer buffer generate wrong results

2011-07-11 Thread Streets Of Boston
In the preview, the data is not RGB. It is yuv_420 or a similar format. 
Query the camera-parameters for the exact format and decode the data 
accordingly.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: converting RGB565 byte array to integer buffer generate wrong results

2011-07-11 Thread Qianqian Fang
On Jul 11, 4:50 pm, Streets Of Boston  wrote:
> In the preview, the data is not RGB. It is yuv_420 or a similar format.
> Query the camera-parameters for the exact format and decode the data
> accordingly.

hi

thanks for your comment. In the "..." part of my original post, I
did call "param.setPreviewFormat(PixelFormat.RGB_565)" to
explicitly set the pixel format of the preview. I verified it by
decoding the resulting byte buffer using an RGB_565-encoded
bitmap "bmp=new Bitmap.createBitmap(320,480, Bitmap.Config.RGB_565)"
and display the decoded bitmap to an imageview; the image looked
ok. So, I am reasonably confident that the preview is RGB_565
encoded.

Can anything else in my code mess up the decoding/recording?

thanks

Qianqian

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: converting RGB565 byte array to integer buffer generate wrong results

2011-07-11 Thread Qianqian Fang

On Jul 11, 4:50 pm, Streets Of Boston  wrote:
> In the preview, the data is not RGB. It is yuv_420 or a similar format.
> Query the camera-parameters for the exact format and decode the data
> accordingly.

problem found! it was caused by endianness of the data. By inserting

 byteBuf.order(ByteOrder.LITTLE_ENDIAN);

before saving the buffer, the results became reasonable.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: converting RGB565 byte array to integer buffer generate wrong results

2011-07-11 Thread Streets Of Boston
Don't count on the hardware of the camera that it can handle RGB. Just get 
the preview-format and decode it accordingly (yuv format).

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en