0

I faced weird issue using Nexus 5 with Android 5.0.1. I have a camera app, which has capture button, that captures frame from SurfacePreview and saves it to file:

public void takePicture(final Context context) {
    PictureCallback pictureCallback = new PictureCallback() {

        @Override
        public void onPictureTaken(byte[] data, Camera camera) {
            File pictureFile = StorageUtils.getOutputMediaFile(context, mIsForeside, null);
            if (pictureFile == null) {
                return;
            }
            InputStream is = new ByteArrayInputStream(data);    
            Bitmap bmp = BitmapFactory.decodeStream(is);
            FileOutputStream out = null;
            try {
                out = new FileOutputStream(pictureFile);
                bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
            } catch (Exception e) {
            } finally {
                try {
                    out.close();
                } catch (Throwable ignore) {

                }
            }
            mOnPictureTakenListener.OnPictureTaken(pictureFile.getAbsolutePath());
        }
    };

    mCamera.takePicture(null, null, pictureCallback);
}

This code works just fine on Nexus 5 running Android 4.4, but on Nexus with Android 5.0.1 I see following artifact:

Photo with artifact

Has anyone aware of this issue?

Cœur
  • 37,241
  • 25
  • 195
  • 267
mol
  • 2,607
  • 4
  • 21
  • 40
  • I resolved the problem by implementing TextureView instead of SurfaceView using camera pre-lollipop api. – mol Feb 09 '15 at 12:34

1 Answers1

1

Did you try to save data byte array into JPEG file, without bitmap converting?

Since android 5, google introduce new camera API. May be you should try to use it?

Maxim Metelskiy
  • 1,389
  • 14
  • 29
  • Yes, I tried saving to JPEG, no result. Thanks for suggestion, I'll try camera2 api. – mol Jan 16 '15 at 09:42