diff options
author | Jack Yoo <jyoo@codeaurora.org> | 2016-05-10 14:11:19 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-08-25 21:55:20 -0700 |
commit | eb2e8a2a4da18f97462ca7f67429a135d2dc2df5 (patch) | |
tree | afb53e1c1652cef9ed5d35266fa58d8be21e450c /src/com/android/camera/imageprocessor/PostProcessor.java | |
parent | 3e54ea242b405155fade948203ddd3d3143be986 (diff) | |
download | android_packages_apps_Snap-eb2e8a2a4da18f97462ca7f67429a135d2dc2df5.tar.gz android_packages_apps_Snap-eb2e8a2a4da18f97462ca7f67429a135d2dc2df5.tar.bz2 android_packages_apps_Snap-eb2e8a2a4da18f97462ca7f67429a135d2dc2df5.zip |
SnapdragonCamera: Sharpshooter post filter
Adding Sharpshooter post process filter
Change-Id: I8f3c1962db437e7dfbe2973f806a3f9a26480eb7
CRs-Fixed: 1023183
Diffstat (limited to 'src/com/android/camera/imageprocessor/PostProcessor.java')
-rw-r--r-- | src/com/android/camera/imageprocessor/PostProcessor.java | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/com/android/camera/imageprocessor/PostProcessor.java b/src/com/android/camera/imageprocessor/PostProcessor.java index a126e8817..f39845346 100644 --- a/src/com/android/camera/imageprocessor/PostProcessor.java +++ b/src/com/android/camera/imageprocessor/PostProcessor.java @@ -43,17 +43,24 @@ import android.widget.Toast; import com.android.camera.CameraActivity; import com.android.camera.CaptureModule; +import com.android.camera.Exif; import com.android.camera.MediaSaveService; import com.android.camera.PhotoModule; import com.android.camera.SettingsManager; +import com.android.camera.exif.ExifInterface; import com.android.camera.imageprocessor.filter.OptizoomFilter; +import com.android.camera.imageprocessor.filter.SharpshooterFilter; import com.android.camera.ui.RotateTextToast; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; +import java.util.TimeZone; + import com.android.camera.imageprocessor.filter.ImageFilter; +import com.android.camera.util.CameraUtil; public class PostProcessor implements ImageReader.OnImageAvailableListener{ @@ -62,7 +69,8 @@ public class PostProcessor implements ImageReader.OnImageAvailableListener{ private static final String TAG = "PostProcessor"; public static final int FILTER_NONE = 0; public static final int FILTER_OPTIZOOM = 1; - public static final int FILTER_MAX = 2; + public static final int FILTER_SHARPSHOOTER = 2; + public static final int FILTER_MAX = 3; private int mCurrentNumImage = 0; private ImageFilter mFilter; @@ -80,7 +88,7 @@ public class PostProcessor implements ImageReader.OnImageAvailableListener{ private WatchdogThread mWatchdog; //This is for the debug feature. - private static boolean DEBUG_FILTER = true; //TODO: This has to be false before releasing. + private static boolean DEBUG_FILTER = false; private ImageFilter.ResultImage mDebugResultImage; @Override @@ -258,6 +266,9 @@ public class PostProcessor implements ImageReader.OnImageAvailableListener{ case FILTER_OPTIZOOM: mFilter = new OptizoomFilter(mController); break; + case FILTER_SHARPSHOOTER: + mFilter = new SharpshooterFilter(mController); + break; } } @@ -363,6 +374,20 @@ public class PostProcessor implements ImageReader.OnImageAvailableListener{ }); } + private byte[] addExifTags(byte[] jpeg, int orientationInDegree) { + ExifInterface exif = new ExifInterface(); + exif.addOrientationTag(orientationInDegree); + exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME, System.currentTimeMillis(), + TimeZone.getDefault()); + ByteArrayOutputStream jpegOut = new ByteArrayOutputStream(); + try { + exif.writeExif(jpeg, jpegOut); + } catch (IOException e) { + Log.e(TAG, "Could not write EXIF", e); + } + return jpegOut.toByteArray(); + } + private void clear() { mCurrentNumImage = 0; } @@ -409,29 +434,32 @@ public class PostProcessor implements ImageReader.OnImageAvailableListener{ ) { Log.e(TAG, "Processed outRoi is not within picture range"); } else { + int orientation = CameraUtil.getJpegRotation(mController.getMainCameraId(), mController.getDisplayOrientation()); if(mFilter != null && DEBUG_FILTER) { - bytes = nv21ToJpeg(mDebugResultImage); + bytes = nv21ToJpeg(mDebugResultImage, orientation); mActivity.getMediaSaveService().addImage( bytes, title + "_beforeApplyingFilter", date, null, mDebugResultImage.outRoi.width(), mDebugResultImage.outRoi.height(), - 0, null, mediaSavedListener, contentResolver, "jpeg"); + orientation, null, mediaSavedListener, contentResolver, "jpeg"); } - bytes = nv21ToJpeg(resultImage); - mController.updateThumbnailJpegData(bytes); + bytes = nv21ToJpeg(resultImage, orientation); mActivity.getMediaSaveService().addImage( bytes, title, date, null, resultImage.outRoi.width(), resultImage.outRoi.height(), - 0, null, mediaSavedListener, contentResolver, "jpeg"); + orientation, null, mediaSavedListener, contentResolver, "jpeg"); + mController.updateThumbnailJpegData(bytes); } } } }); } - private byte[] nv21ToJpeg(ImageFilter.ResultImage resultImage) { + private byte[] nv21ToJpeg(ImageFilter.ResultImage resultImage, int orientation) { BitmapOutputStream bos = new BitmapOutputStream(1024); YuvImage im = new YuvImage(resultImage.outBuffer.array(), ImageFormat.NV21, resultImage.width, resultImage.height, new int[]{resultImage.stride, resultImage.stride}); im.compressToJpeg(resultImage.outRoi, 50, bos); - return bos.getArray(); + byte[] bytes = bos.getArray(); + bytes = addExifTags(bytes, orientation); + return bytes; } private class BitmapOutputStream extends ByteArrayOutputStream { |