summaryrefslogtreecommitdiff
path: root/graphics/java
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-10-17 14:26:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-10-17 14:26:46 +0000
commit017cbabdce24d7a8f2d83a58468a337a9509c060 (patch)
treed052cb286bd3f0362ac60899c34c5266cba616a8 /graphics/java
parentc111baae8353a930a273e99fa0f6c3f1ca1ebb89 (diff)
parent94d294bb5215719363a746a6371abe9bb1100626 (diff)
Merge "Add Bitmap.CompressFormat#WEBP_LOSSY/LOSSLESS"
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/graphics/Bitmap.java47
1 files changed, 40 insertions, 7 deletions
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index 44710178da5e..d900a42b1e66 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -1359,9 +1359,44 @@ public final class Bitmap implements Parcelable {
* Specifies the known formats a bitmap can be compressed into
*/
public enum CompressFormat {
- JPEG (0),
- PNG (1),
- WEBP (2);
+ /**
+ * Compress to the JPEG format. {@code quality} of {@code 0} means
+ * compress for the smallest size. {@code 100} means compress for max
+ * visual quality.
+ */
+ JPEG (0),
+ /**
+ * Compress to the PNG format. PNG is lossless, so {@code quality} is
+ * ignored.
+ */
+ PNG (1),
+ /**
+ * Compress to the WEBP format. {@code quality} of {@code 0} means
+ * compress for the smallest size. {@code 100} means compress for max
+ * visual quality. As of {@link android.os.Build.VERSION_CODES#Q}, a
+ * value of {@code 100} results in a file in the lossless WEBP format.
+ * Otherwise the file will be in the lossy WEBP format.
+ *
+ * @deprecated in favor of the more explicit
+ * {@link CompressFormat#WEBP_LOSSY} and
+ * {@link CompressFormat#WEBP_LOSSLESS}.
+ */
+ @Deprecated
+ WEBP (2),
+ /**
+ * Compress to the WEBP lossy format. {@code quality} of {@code 0} means
+ * compress for the smallest size. {@code 100} means compress for max
+ * visual quality.
+ */
+ WEBP_LOSSY (3),
+ /**
+ * Compress to the WEBP lossless format. {@code quality} refers to how
+ * much effort to put into compression. A value of {@code 0} means to
+ * compress quickly, resulting in a relatively large file size.
+ * {@code 100} means to spend more time compressing, resulting in a
+ * smaller file.
+ */
+ WEBP_LOSSLESS (4);
CompressFormat(int nativeInt) {
this.nativeInt = nativeInt;
@@ -1385,10 +1420,8 @@ public final class Bitmap implements Parcelable {
* pixels).
*
* @param format The format of the compressed image
- * @param quality Hint to the compressor, 0-100. 0 meaning compress for
- * small size, 100 meaning compress for max quality. Some
- * formats, like PNG which is lossless, will ignore the
- * quality setting
+ * @param quality Hint to the compressor, 0-100. The value is interpreted
+ * differently depending on the {@link CompressFormat}.
* @param stream The outputstream to write the compressed data.
* @return true if successfully compressed to the specified stream.
*/