hi,
    Thanks for your reply, please can you send me a sample code of 
Bitmap.compress(..) that can help me. where here is my code to compress it to 
jpeg


public void onPreviewFrame(byte[] data, Camera camera) {  
            
            
            Camera.Parameters parameters = camera.getParameters();
            int format = parameters.getPreviewFormat();

             //YUV formats require more conversion
            if (format == ImageFormat.NV21 /*|| format == ImageFormat.YUY2 || 
format == ImageFormat.NV16*/)
            {
                int w = parameters.getPreviewSize().width;
                int h = parameters.getPreviewSize().height;
                // Get the YuV image
                YuvImage yuv_image = new YuvImage(data, format, w, h, null);
                // Convert YuV to Jpeg
                Rect rect = new Rect(0, 0, w, h);
                ByteArrayOutputStream output_stream = new 
ByteArrayOutputStream();
                yuv_image.compressToJpeg(rect, 100, output_stream);
                byte[] byt=output_stream.toByteArray();

it gives me 768x428 size of images. i want the QVGA size that is quarter the 
size of normal VGA image, and it doesn't metter how the quality is. Please tell 
me Bitmap.compress(..) is a something 
different technique ? or suggest me another best technique for implementation. 
and on server side i want to create a video with these images.


Thanks


 

> Subject: Re: [android-developers] How to compress images in onPreviewframe??
> From: har...@gmail.com
> Date: Thu, 12 Jan 2012 16:33:20 +0200
> To: android-developers@googlegroups.com
> 
> Hi,
> 
> If you want to have 2-3KB image size it has to be very small by dimension and 
> compressed using very low quality. You can try different values on 
> Bitmap.compress(..) but I doubt you will ever achieve good enough quality 
> with such a small filesize requirement.
> 
> --
> H
> 
> On Jan 12, 2012, at 3:56 PM, muhammad.ume...@hotmail.com wrote:
> 
> > hi,
> >     I am trying stream video from android to network and receiving it
> > on a server that I had written in java.
> > I am capturing YUV data on onPreviewFrame method on Camera convert
> > with yuv in jpeg and sending it to the server where I convert this
> > data to image and displaying it.
> > 
> > verything works fine but the size of the image is too large in KB to
> > send on network that are 20-30 kb, I want to reduce the size(KB)
> > approximately 2-3 kb. please tell me how can i reduce the size? Is it
> > possible?
> > 
> > Thanks and regards
> > 
> > umer
> > 
> > -- 
> > 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
> 
> -- 
> 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
                                          

-- 
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