Hi, Read this post it might help.
http://groups.google.com/group/android-developers/browse_thread/thread/65796050ccf3e022/067df0e92c366937?lnk=gst&q=compressToJpeg#067df0e92c366937 or search for compressToJpeg in this forum. regards On Apr 26, 3:11 pm, Taylor Niver <[email protected]> wrote: > Also, much of the code has been copied from various sources online, it is > not 100% mine > > > > > > > > On Thursday, April 26, 2012 1:09:23 AM UTC-4, Taylor Niver wrote: > > > The code below works but it is returning images like this > > :IMG<https://lh5.googleusercontent.com/-Tg7Yq8UzcmI/T5jYONjgOVI/AAAAAAAABI...> > > . > > Is there something wrong with my code where it is not receiving the correct > > byte array from the surface holder? > > > -Taylor > > >> public void surfaceChanged(SurfaceHolder holder, int format, int width, > >> int height) { > >> Camera.Parameters parameters = camera.getParameters(); > >> parameters.setPictureFormat(ImageFormat.YUY2); > >> //parameters.setPreviewFormat(ImageFormat.JPEG); > >> camera.setParameters(parameters); > >> camera.startPreview(); > > >> camera.setPreviewCallback(new PreviewCallback(){ > >> @Override > >> public void onPreviewFrame(byte[] _data, Camera camera){ > >> YuvImage im = new YuvImage(_data, ImageFormat.YUY2, 540, > >> 884, null); > >> Rect r = new Rect(0,0,540,884); > >> ByteArrayOutputStream baos = new ByteArrayOutputStream(); > >> im.compressToJpeg(r, 100, baos); > >> try{ > >> FileOutputStream output = new FileOutputStream(String.format( > >> "/sdcard/%s%d.jpg", strPrevCBType, System.currentTimeMillis())); > >> output.write(baos.toByteArray()); > >> output.flush(); > >> output.close(); > >> }catch(FileNotFoundException e){ > >> Log.d("ERROR", e.toString()); > >> }catch(IOException e){ > >> } > >> } > >> }); -- 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

