here's an example of the YUV conversion:
http://blog.tomgibara.com/post/132956174/yuv420-to-rgb565-conversion-in-android


On Jul 1, 2:30 am, newbyca <[email protected]> wrote:
> i'm working with the camera preview in my current project ... one
> thing that has helped me out *a lot* is the zebra crossing (zx) code:
>
> http://code.google.com/p/zxing/source/browse/
>
> specifically, zx parses a small region from the preview data to
> determine if it contains a barcode. if a barcode is found, the region
> is then passed around as a bitmap ... so your answer is *kinda* there.
> i say *kinda* because its a little more complicated than that, and too
> complicated to just post a code snippet ... or at least it is as far
> as I know :)
>
> one thing you'll notice from the zx code is that the preview data is
> not RGB color encoded. that is, if you read the preview data byte for
> byte, it won't be laid out in simple frames of RGB triplets. in fact,
> their code assumes the preview data is encoded using a YUV scheme
> (http://en.wikipedia.org/wiki/YUV). this is normal for video\camera
> equipment and a safe assumption. but the reason i bring it up is that
> if you want to draw a bitmap using preview data, you must do it in
> terms of RGB. i.e., you will have to translate from YUV to RGB at some
> point. this translation isn't too hard tho ... the wiki contains the
> formulas.
>
> HTH//
>
> On May 16, 6:53 am, "[email protected]" <[email protected]> wrote:
>
>
>
> > Hi there,
>
> > I need to capture an image from camera and display on surfaceview for
> > my project. I am trying to obtain bitmap from data in onPreviewFrame
> > method of previewCallback and display on surface using canvas.
>
> > Can someone please help me?
>
> > Following steps were done:
>
> > - created a Preview class extending SurfaceView and implementing
> > SurfaceHolder.Callback set it as the content of activity.
>
> > - installed a SurfaceHolder.Callback in my Preview to get notified
> > when the underlying surface is created and destroyed.
> > mHolder = getHolder();
> > mHolder.addCallback(this);
> > //mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
>
> > - started a thread in surfaceCreated method described as follows:
>
> > public void run() {
> >                                 // Open the Camera
> >                                 camera = Camera.open();
>
> >                                 if (camera != null) {
> >                                          try {
> >                                                
> > camera.setPreviewDisplay(mHolder);
> >                                          } catch (IOException e) {
> >                                                         // TODO 
> > Auto-generated catch block
> >                                                         e.printStackTrace();
> >                                         }
>
> >                                 camera.startPreview();
> >                                 ImageCaptureCallback iccb = new 
> > ImageCaptureCallback ();
> >                                 camera.setPreviewCallback(iccb);
> >                                 }
>
> > ----------
>
> > public class ImageCaptureCallback implements PreviewCallback {
>
> >                 public void onPreviewFrame(byte[] data, Camera camera) {
> >                //ToDo
> >             }
>
> > Please help. I can explain my problem in detail if anybody wish to
> > solve it....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to