Hi,
    thanks for reply, i am using this code snippet to save files on SD Card but 
the image size is to much e.g above 100 kb . but i want to reduce this size to 
1kb, is it possible and if it is possible then what i change in my code. 
basically i want to combine these images and  make a video with these images. 
thanks in advance 


camera.setPreviewCallback(new PreviewCallback() { // <10>
        // Called for each frame previewed
        public void onPreviewFrame(byte[] data, Camera camera) {  // <11>
            
            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();
                
                FileOutputStream outStream = null;
                try {
                    outStream = new FileOutputStream(String.format(
                            "/sdcard/%d.jpg", System.currentTimeMillis()));
                    outStream.write(byt);
                    outStream.close();
               
                     Log.d(TAG, "onPreviewFrame - wrote bytes: "
                            + data.length);
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                }
                Preview.this.invalidate();
                
            }
        }
      });
thanks and regards
umer

Date: Sat, 10 Dec 2011 06:28:25 -0800
From: l...@bendlin.us
To: android-developers@googlegroups.com
Subject: [android-developers] Re: How to reduce the size of image in (kb) from 
Camera onpreviewframe???

take the picture, then transform it to the required size and save as jpeg with 
the appropriate level of compression.  What have you tried?



-- 

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