Android Question Camera.PreviewToJPEG

Cableguy

Expert
Licensed User
Longtime User
Hi Guys,

I have searched the forum but found nothing directly or even remotely related to this subject...

I have an "almost done" app, in which I decided to add a last minute feature...
I'm using camera along with cameraEx, and I want to capture a still frame, but not saving it...
From all I could gather from the camera lib docs, this method may do what I need... but...
How do I use it??

Cam.PreviewImageToJpeg(GetDeviceLayoutValues() as Byte, quality as Int) as Byte()

please help
 
Based on the source i can see (camEx class);

something like
Code: Copy
Sub Camera1_PictureTaken (Data() As Byte)
    Dim jpg() As Byte = camEx.PreviewImageToJpeg(Data,100)
    'save the bytearray to a file now if you want
i guess
 
Upvote 0
As I said, I do not want to save the resulting image, only to make it "still" on screen.... how would I apply that byte array to an image?
 
Upvote 0
how would I apply that byte array to an image?
it is not really working for me using Previewimagetojpg....

But if i use the data array in the picture taken event then i can get it work with

Code: Copy
Sub Camera1_PictureTaken (Data() As Byte)
    'Dim jpg() As Byte = camEx.PreviewImageToJpeg(Data,100)
    Dim inps As InputStream
    inps.InitializeFromBytesArray(Data,0,Data.Length)
    Dim bmp As Bitmap
    bmp.Initialize2(inps)
    inps.Close
    ImageView1.Bitmap = bmp
 
Upvote 0
Thanks Don,

I had found a snippet that uses the same principle... Indeed, I first have to call "takePicture" in order to get the data in the picturetaken event...
I never really worked with byte streams, so I was a bit lost.

Thanks for taking the time to help me
 
Upvote 0
Hi

If you just want to freeze the image, you can call CamEx.stopPreview

If you need the bitmap of the still image to process it or whatever, you can take a look here , and instead of calling it in every preview frame (as it is done in the example), call the routine only once when you want a "photo" of the preview, and show it on top of the preview panel
 
Upvote 0
Hi guys, I urgently need help.

I need to be able to get the image from the preview event as an image (jpg/bmp).

My issue is that the device I need to use is Android 2.2! Which means no CameraEx :-(

Any help would be greatly appreciated!!!
 
Upvote 0

Similar Threads

Back
Top