In your  'public void onPictureTaken(byte[] data, Camera camera)'
method
You have to create a BMP out of the 'data'. The 'data' is not JPEG. It
is RGB data (if i'm not mistaken).

  Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);

Then you compress the bitmap into jpeg.

  bmp.compress(...) to create a PNG or JPEG file.

A side note: If you want to avoid the MediaScanner to have to run
before your gallery can actually see the proper picture, supply the
DATA column in your insert statement (add it to the ContentValues).
The value of the DATA column is a string, it is the fully-qualified
path-name to your JPEG or PNG file.

On Nov 24, 10:27 am, Joel <joelefisc...@googlemail.com> wrote:
> In my application users take photos with an Activity that implements
> SurfaceHolder.Callback. The uri.toString() is then passed as an extra
> to a subsequent Activity that displays the image. All fine, except for
> in Android 1.6 the jpgs on the sdcard have a strange noise when
> looking at them through mac finder or win explorer after mounting the
> sdcard. The images have purple and yellow stripes on their upper half.
> Fine on camera gallery.
>
> Here's some (hopefully) relevant code.
>
> The fact that it works on 1.5 and not 1.6 points to some underlying
> problems..? Is this a known issue?
>
> <code>
> private OnClickListener shutterListener = new OnClickListener() {
>         public void onClick(View v) {
>                 ImageCaptureCallback iccb = null;
>                 filename = System.currentTimeMillis()+"";
>                         ContentValues values = new ContentValues();
>                         values.put(Media.TITLE, filename);
>                         values.put(Media.DESCRIPTION, "my_photos");
>                 uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,
> values);
>                 try {
>                         iccb = new ImageCaptureCallback( getContentResolver
> ().openOutputStream(uri));
>                 } catch (FileNotFoundException ce) {Log.e(getClass
> ().getSimpleName(),ce.toString());}
>                 //take the pic
>                 camera.takePicture(mShutterCallback, mPictureCallbackRaw,
> iccb);
>
> }
>
> .....
>
> public class ImageCaptureCallback implements PictureCallback  {
>
>                 private OutputStream filoutputStream;
>                 public ImageCaptureCallback(OutputStream filoutputStream) {
>                         this.filoutputStream = filoutputStream;
>                 }
>
>                 public void onPictureTaken(byte[] data, Camera camera) {
>
>                         try {
>                                 filoutputStream.write(data);
>                                 filoutputStream.flush();
>                                 filoutputStream.close();
>
>                         } catch(Exception ex) {
>                                 ex.printStackTrace();
>                         }
>                         startNextActivity();
>                 }
>         }
>
> protected void startNextActivity() {
>                 Log.d("CameraActivity","starting next activity...");
>                 startActivity( new Intent(CameraActivity.this,
> ImageAccepter.class).putExtra("pic", uri.toString()));
>         }
>
> </code>

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