From fb7c5cfa090d55155aea350bda8668e9ad2df92f Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 2 Mar 2018 22:13:20 +0100 Subject: [PATCH] Remove JpegQuality --- MIGRATION.md | 4 +++ README.md | 11 ------- .../cameraview/CameraViewTest.java | 14 --------- .../otaliastudios/cameraview/CameraView.java | 31 ++----------------- cameraview/src/main/res/values/attrs.xml | 2 -- 5 files changed, 7 insertions(+), 55 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index 7c46ca93..ab32ae67 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -1 +1,5 @@ # Migrating to v2 + +- JpegQuality: both cameraJpegQuality and setJpegQuality() have been removed, because + they were working only with specific setups. We'll use the default quality provided + by the camera engine. \ No newline at end of file diff --git a/README.md b/README.md index 77e65ccd..3de0666f 100644 --- a/README.md +++ b/README.md @@ -410,7 +410,6 @@ Most camera parameters can be controlled through XML attributes or linked method app:cameraGrid="off" app:cameraSessionType="picture" app:cameraCropOutput="false" - app:cameraJpegQuality="100" app:cameraVideoQuality="max480p" app:cameraVideoCodec="deviceDefault" app:cameraWhiteBalance="auto" @@ -428,7 +427,6 @@ Most camera parameters can be controlled through XML attributes or linked method |[`cameraFlash`](#cameraflash)|`setFlash()`|`off` `on` `auto` `torch`|`off`| |[`cameraGrid`](#cameragrid)|`setGrid()`|`off` `draw3x3` `draw4x4` `drawPhi`|`off`| |[`cameraCropOutput`](#cameracropoutput)|`setCropOutput()`|`true` `false`|`false`| -|[`cameraJpegQuality`](#camerajpegquality)|`setJpegQuality()`|`0 < n <= 100`|`100`| |[`cameraVideoQuality`](#cameravideoquality)|`setVideoQuality()`|`lowest` `highest` `maxQvga` `max480p` `max720p` `max1080p` `max2160p`|`max480p`| |[`cameraVideoCodec`](#cameravideocodec)|`setVideoCodec()`|`deviceDefault` `h263` `h264`|`deviceDefault`| |[`cameraWhiteBalance`](#camerawhitebalance)|`setWhiteBalance()`|`auto` `incandescent` `fluorescent` `daylight` `cloudy`|`auto`| @@ -496,15 +494,6 @@ Whether the output picture should be cropped to fit the aspect ratio of the prev This can guarantee consistency between what the user sees and the final output, if you fixed the camera view dimensions. This does not support videos. -#### cameraJpegQuality - -Sets the JPEG quality of pictures. - -```java -cameraView.setJpegQuality(100); -cameraView.setJpegQuality(50); -``` - #### cameraVideoQuality Sets the desired video quality. diff --git a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java index 7c539bf6..a32c616b 100644 --- a/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java +++ b/cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java @@ -103,7 +103,6 @@ public class CameraViewTest extends BaseTest { // Self managed assertEquals(cameraView.getPlaySounds(), CameraView.DEFAULT_PLAY_SOUNDS); assertEquals(cameraView.getCropOutput(), CameraView.DEFAULT_CROP_OUTPUT); - assertEquals(cameraView.getJpegQuality(), CameraView.DEFAULT_JPEG_QUALITY); assertEquals(cameraView.getGestureAction(Gesture.TAP), GestureAction.DEFAULT_TAP); assertEquals(cameraView.getGestureAction(Gesture.LONG_TAP), GestureAction.DEFAULT_LONG_TAP); assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.DEFAULT_PINCH); @@ -467,14 +466,6 @@ public class CameraViewTest extends BaseTest { assertFalse(cameraView.getCropOutput()); } - @Test - public void testSetJpegQuality() { - cameraView.setJpegQuality(10); - assertEquals(cameraView.getJpegQuality(), 10); - cameraView.setJpegQuality(100); - assertEquals(cameraView.getJpegQuality(), 100); - } - @Test public void testSetPlaySounds() { cameraView.setPlaySounds(true); @@ -483,11 +474,6 @@ public class CameraViewTest extends BaseTest { assertEquals(cameraView.getPlaySounds(), false); } - @Test(expected = IllegalArgumentException.class) - public void testSetJpegQuality_illegal() { - cameraView.setJpegQuality(-10); - } - @Test public void testSetFlash() { cameraView.set(Flash.TORCH); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index 3f44b18e..edc57343 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -50,12 +50,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver { public final static int PERMISSION_REQUEST_CODE = 16; - final static int DEFAULT_JPEG_QUALITY = 100; final static boolean DEFAULT_CROP_OUTPUT = false; final static boolean DEFAULT_PLAY_SOUNDS = true; // Self managed parameters - private int mJpegQuality; private boolean mCropOutput; private boolean mPlaySounds; private HashMap mGestureMap = new HashMap<>(4); @@ -100,7 +98,6 @@ public class CameraView extends FrameLayout implements LifecycleObserver { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CameraView, 0, 0); // Self managed - int jpegQuality = a.getInteger(R.styleable.CameraView_cameraJpegQuality, DEFAULT_JPEG_QUALITY); boolean cropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, DEFAULT_CROP_OUTPUT); boolean playSounds = a.getBoolean(R.styleable.CameraView_cameraPlaySounds, DEFAULT_PLAY_SOUNDS); @@ -175,7 +172,6 @@ public class CameraView extends FrameLayout implements LifecycleObserver { // Apply self managed setCropOutput(cropOutput); - setJpegQuality(jpegQuality); setPlaySounds(playSounds); // Apply camera controller params @@ -1074,27 +1070,6 @@ public class CameraView extends FrameLayout implements LifecycleObserver { } - /** - * Sets the JPEG compression quality for image outputs. - * @param jpegQuality a 0-100 integer. - */ - public void setJpegQuality(int jpegQuality) { - if (jpegQuality <= 0 || jpegQuality > 100) { - throw new IllegalArgumentException("JPEG quality should be > 0 and <= 100"); - } - mJpegQuality = jpegQuality; - } - - - /** - * Gets the JPEG compression quality for image outputs. - * @return a 0-100 integer - */ - public int getJpegQuality() { - return mJpegQuality; - } - - /** * Whether we should crop the picture output to match CameraView aspect ratio. * This is only relevant if CameraView dimensions were somehow constrained @@ -1587,7 +1562,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver { AspectRatio targetRatio = AspectRatio.of(w, h); mLogger.i("processImage", "is consistent?", consistentWithView); mLogger.i("processImage", "viewWidth?", getWidth(), "viewHeight?", getHeight()); - jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, mJpegQuality); + jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, 100); } dispatchOnPictureTaken(jpeg2); } @@ -1607,10 +1582,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver { AspectRatio targetRatio = AspectRatio.of(w, h); mLogger.i("processSnapshot", "is consistent?", consistentWithView); mLogger.i("processSnapshot", "viewWidth?", getWidth(), "viewHeight?", getHeight()); - jpeg = CropHelper.cropToJpeg(yuv, targetRatio, mJpegQuality); + jpeg = CropHelper.cropToJpeg(yuv, targetRatio, 100); } else { 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()), 100, out); jpeg = out.toByteArray(); } dispatchOnPictureTaken(jpeg); diff --git a/cameraview/src/main/res/values/attrs.xml b/cameraview/src/main/res/values/attrs.xml index 53abcd38..3fa16da2 100644 --- a/cameraview/src/main/res/values/attrs.xml +++ b/cameraview/src/main/res/values/attrs.xml @@ -89,8 +89,6 @@ - -