you need to tell me a little more about the issue ... but my guess is
you were seeing something like "Bitmap to big for allocated memory" or
something or other? i forgot exactly, but i've seen an error like that
before trying to write to bitmaps. again, this is just a guess, but
are you creating a new Bitmap object in each call to onPreviewFrame?
If so, that's a no-no :)

Instead, make your Bitmap class scoped and flush it out each time.

hth, chris

On Jul 4, 5:22 am, lori <loril...@gmail.com> wrote:
> thanks for the reply,
>
> I tried to convert the YUV data in first preview frame in
> onPreviewFrame() to RGB and then convert it to bitmap using the YUV
> conversion provided.
> But I get an out of memory issue within a second. Can you please help
> me out?
>
> On Jul 2, 3:15 am, newbyca <newb...@gmail.com> wrote:
>
>
>
> > here's an example of the YUV 
> > conversion:http://blog.tomgibara.com/post/132956174/yuv420-to-rgb565-conversion-...
>
> > On Jul 1, 2:30 am, newbyca <newb...@gmail.com> 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, "loril...@gmail.com" <loril...@gmail.com> 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 inonPreviewFrame
> > > > 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 voidonPreviewFrame(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 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to