Remove JpegQuality

v2
Mattia Iavarone 7 years ago
parent 778ee7a79e
commit 74a4bac091
  1. 4
      MIGRATION.md
  2. 11
      README.md
  3. 14
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewTest.java
  4. 31
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  5. 2
      cameraview/src/main/res/values/attrs.xml

@ -1 +1,5 @@
# Migrating to v2 # 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.

@ -410,7 +410,6 @@ Most camera parameters can be controlled through XML attributes or linked method
app:cameraGrid="off" app:cameraGrid="off"
app:cameraSessionType="picture" app:cameraSessionType="picture"
app:cameraCropOutput="false" app:cameraCropOutput="false"
app:cameraJpegQuality="100"
app:cameraVideoQuality="max480p" app:cameraVideoQuality="max480p"
app:cameraVideoCodec="deviceDefault" app:cameraVideoCodec="deviceDefault"
app:cameraWhiteBalance="auto" 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`| |[`cameraFlash`](#cameraflash)|`setFlash()`|`off` `on` `auto` `torch`|`off`|
|[`cameraGrid`](#cameragrid)|`setGrid()`|`off` `draw3x3` `draw4x4` `drawPhi`|`off`| |[`cameraGrid`](#cameragrid)|`setGrid()`|`off` `draw3x3` `draw4x4` `drawPhi`|`off`|
|[`cameraCropOutput`](#cameracropoutput)|`setCropOutput()`|`true` `false`|`false`| |[`cameraCropOutput`](#cameracropoutput)|`setCropOutput()`|`true` `false`|`false`|
|[`cameraJpegQuality`](#camerajpegquality)|`setJpegQuality()`|`0 < n <= 100`|`100`|
|[`cameraVideoQuality`](#cameravideoquality)|`setVideoQuality()`|`lowest` `highest` `maxQvga` `max480p` `max720p` `max1080p` `max2160p`|`max480p`| |[`cameraVideoQuality`](#cameravideoquality)|`setVideoQuality()`|`lowest` `highest` `maxQvga` `max480p` `max720p` `max1080p` `max2160p`|`max480p`|
|[`cameraVideoCodec`](#cameravideocodec)|`setVideoCodec()`|`deviceDefault` `h263` `h264`|`deviceDefault`| |[`cameraVideoCodec`](#cameravideocodec)|`setVideoCodec()`|`deviceDefault` `h263` `h264`|`deviceDefault`|
|[`cameraWhiteBalance`](#camerawhitebalance)|`setWhiteBalance()`|`auto` `incandescent` `fluorescent` `daylight` `cloudy`|`auto`| |[`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 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. the camera view dimensions. This does not support videos.
#### cameraJpegQuality
Sets the JPEG quality of pictures.
```java
cameraView.setJpegQuality(100);
cameraView.setJpegQuality(50);
```
#### cameraVideoQuality #### cameraVideoQuality
Sets the desired video quality. Sets the desired video quality.

@ -103,7 +103,6 @@ public class CameraViewTest extends BaseTest {
// Self managed // Self managed
assertEquals(cameraView.getPlaySounds(), CameraView.DEFAULT_PLAY_SOUNDS); assertEquals(cameraView.getPlaySounds(), CameraView.DEFAULT_PLAY_SOUNDS);
assertEquals(cameraView.getCropOutput(), CameraView.DEFAULT_CROP_OUTPUT); 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.TAP), GestureAction.DEFAULT_TAP);
assertEquals(cameraView.getGestureAction(Gesture.LONG_TAP), GestureAction.DEFAULT_LONG_TAP); assertEquals(cameraView.getGestureAction(Gesture.LONG_TAP), GestureAction.DEFAULT_LONG_TAP);
assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.DEFAULT_PINCH); assertEquals(cameraView.getGestureAction(Gesture.PINCH), GestureAction.DEFAULT_PINCH);
@ -467,14 +466,6 @@ public class CameraViewTest extends BaseTest {
assertFalse(cameraView.getCropOutput()); assertFalse(cameraView.getCropOutput());
} }
@Test
public void testSetJpegQuality() {
cameraView.setJpegQuality(10);
assertEquals(cameraView.getJpegQuality(), 10);
cameraView.setJpegQuality(100);
assertEquals(cameraView.getJpegQuality(), 100);
}
@Test @Test
public void testSetPlaySounds() { public void testSetPlaySounds() {
cameraView.setPlaySounds(true); cameraView.setPlaySounds(true);
@ -483,11 +474,6 @@ public class CameraViewTest extends BaseTest {
assertEquals(cameraView.getPlaySounds(), false); assertEquals(cameraView.getPlaySounds(), false);
} }
@Test(expected = IllegalArgumentException.class)
public void testSetJpegQuality_illegal() {
cameraView.setJpegQuality(-10);
}
@Test @Test
public void testSetFlash() { public void testSetFlash() {
cameraView.set(Flash.TORCH); cameraView.set(Flash.TORCH);

@ -50,12 +50,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
public final static int PERMISSION_REQUEST_CODE = 16; 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_CROP_OUTPUT = false;
final static boolean DEFAULT_PLAY_SOUNDS = true; final static boolean DEFAULT_PLAY_SOUNDS = true;
// Self managed parameters // Self managed parameters
private int mJpegQuality;
private boolean mCropOutput; private boolean mCropOutput;
private boolean mPlaySounds; private boolean mPlaySounds;
private HashMap<Gesture, GestureAction> mGestureMap = new HashMap<>(4); private HashMap<Gesture, GestureAction> 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); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CameraView, 0, 0);
// Self managed // 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 cropOutput = a.getBoolean(R.styleable.CameraView_cameraCropOutput, DEFAULT_CROP_OUTPUT);
boolean playSounds = a.getBoolean(R.styleable.CameraView_cameraPlaySounds, DEFAULT_PLAY_SOUNDS); 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 // Apply self managed
setCropOutput(cropOutput); setCropOutput(cropOutput);
setJpegQuality(jpegQuality);
setPlaySounds(playSounds); setPlaySounds(playSounds);
// Apply camera controller params // 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. * Whether we should crop the picture output to match CameraView aspect ratio.
* This is only relevant if CameraView dimensions were somehow constrained * 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); AspectRatio targetRatio = AspectRatio.of(w, h);
mLogger.i("processImage", "is consistent?", consistentWithView); mLogger.i("processImage", "is consistent?", consistentWithView);
mLogger.i("processImage", "viewWidth?", getWidth(), "viewHeight?", getHeight()); mLogger.i("processImage", "viewWidth?", getWidth(), "viewHeight?", getHeight());
jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, mJpegQuality); jpeg2 = CropHelper.cropToJpeg(jpeg, targetRatio, 100);
} }
dispatchOnPictureTaken(jpeg2); dispatchOnPictureTaken(jpeg2);
} }
@ -1607,10 +1582,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
AspectRatio targetRatio = AspectRatio.of(w, h); AspectRatio targetRatio = AspectRatio.of(w, h);
mLogger.i("processSnapshot", "is consistent?", consistentWithView); mLogger.i("processSnapshot", "is consistent?", consistentWithView);
mLogger.i("processSnapshot", "viewWidth?", getWidth(), "viewHeight?", getHeight()); mLogger.i("processSnapshot", "viewWidth?", getWidth(), "viewHeight?", getHeight());
jpeg = CropHelper.cropToJpeg(yuv, targetRatio, mJpegQuality); jpeg = CropHelper.cropToJpeg(yuv, targetRatio, 100);
} 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()), 100, out);
jpeg = out.toByteArray(); jpeg = out.toByteArray();
} }
dispatchOnPictureTaken(jpeg); dispatchOnPictureTaken(jpeg);

@ -89,8 +89,6 @@
<enum name="video" value="1" /> <enum name="video" value="1" />
</attr> </attr>
<attr name="cameraJpegQuality" format="integer" />
<attr name="cameraVideoQuality" format="enum"> <attr name="cameraVideoQuality" format="enum">
<enum name="lowest" value="0" /> <enum name="lowest" value="0" />
<enum name="highest" value="1" /> <enum name="highest" value="1" />

Loading…
Cancel
Save