The code below works but it is returning images like this 
:IMG<https://lh5.googleusercontent.com/-Tg7Yq8UzcmI/T5jYONjgOVI/AAAAAAAABIU/L1prL75Y-VU/s800/hhh1335413774934.jpg>
 .  
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

Reply via email to