|
|
@ -983,23 +983,20 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
* @param consistentWithView is the final image (decoded respecting EXIF data) consistent with |
|
|
|
* @param consistentWithView is the final image (decoded respecting EXIF data) consistent with |
|
|
|
* the view width and height? Or should we flip dimensions to have a |
|
|
|
* the view width and height? Or should we flip dimensions to have a |
|
|
|
* consistent measure? |
|
|
|
* consistent measure? |
|
|
|
* @param flipPicture whether this picture should be flipped horizontally after decoding, |
|
|
|
* @param flipHorizontally whether this picture should be flipped horizontally after decoding, |
|
|
|
* because it was taken with the front camera. |
|
|
|
* because it was taken with the front camera. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void processJpegPicture(final byte[] jpeg, final boolean consistentWithView, final boolean flipPicture) { |
|
|
|
public void processImage(final byte[] jpeg, final boolean consistentWithView, final boolean flipHorizontally) { |
|
|
|
getWorkerHandler().post(new Runnable() { |
|
|
|
getWorkerHandler().post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
byte[] jpeg2 = jpeg; |
|
|
|
byte[] jpeg2 = jpeg; |
|
|
|
if (mCropOutput) { |
|
|
|
if (mCropOutput && mPreviewImpl.isCropping()) { |
|
|
|
// If consistent, dimensions of the jpeg Bitmap and dimensions of getWidth(), getHeight()
|
|
|
|
// If consistent, dimensions of the jpeg Bitmap and dimensions of getWidth(), getHeight()
|
|
|
|
// Live in the same reference system.
|
|
|
|
// Live in the same reference system.
|
|
|
|
AspectRatio targetRatio; |
|
|
|
int w = consistentWithView ? getWidth() : getHeight(); |
|
|
|
if (consistentWithView) { |
|
|
|
int h = consistentWithView ? getHeight() : getWidth(); |
|
|
|
targetRatio = AspectRatio.of(getWidth(), getHeight()); |
|
|
|
AspectRatio targetRatio = AspectRatio.of(w, h); |
|
|
|
} else { |
|
|
|
|
|
|
|
targetRatio = AspectRatio.of(getHeight(), getWidth()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Log.e(TAG, "is Consistent? " + consistentWithView); |
|
|
|
Log.e(TAG, "is Consistent? " + consistentWithView); |
|
|
|
Log.e(TAG, "viewWidth? " + getWidth() + ", viewHeight? " + getHeight()); |
|
|
|
Log.e(TAG, "viewWidth? " + getWidth() + ", viewHeight? " + getHeight()); |
|
|
|
jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, mJpegQuality); |
|
|
|
jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, mJpegQuality); |
|
|
@ -1010,11 +1007,13 @@ public class CameraView extends FrameLayout implements LifecycleObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void processYuvPicture(YuvImage yuv) { |
|
|
|
public void processSnapshot(YuvImage yuv, boolean consistentWithView, boolean flipHorizontally) { |
|
|
|
byte[] jpeg; |
|
|
|
byte[] jpeg; |
|
|
|
if (mCropOutput) { |
|
|
|
if (mCropOutput && mPreviewImpl.isCropping()) { |
|
|
|
AspectRatio outputRatio = AspectRatio.of(getWidth(), getHeight()); |
|
|
|
int w = consistentWithView ? getWidth() : getHeight(); |
|
|
|
jpeg = CropHelper.cropToJpeg(yuv, outputRatio, mJpegQuality); |
|
|
|
int h = consistentWithView ? getHeight() : getWidth(); |
|
|
|
|
|
|
|
AspectRatio targetRatio = AspectRatio.of(w, h); |
|
|
|
|
|
|
|
jpeg = CropHelper.cropToJpeg(yuv, targetRatio, mJpegQuality); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
|
|
|
yuv.compressToJpeg(new Rect(0, 0, yuv.getWidth(), yuv.getHeight()), mJpegQuality, out); |
|
|
|
yuv.compressToJpeg(new Rect(0, 0, yuv.getWidth(), yuv.getHeight()), mJpegQuality, out); |
|
|
|