Stay organized with collections
Save and categorize content based on your preferences.
class CompressFormat
Specifies the known formats a bitmap can be compressed into
Summary
Enum values |
Compress to the JPEG format.
|
Compress to the PNG format.
|
Compress to the WEBP format.
|
Compress to the WEBP lossless format.
|
Compress to the WEBP lossy format.
|
Enum values
JPEG
enum val JPEG : Bitmap.CompressFormat
Compress to the JPEG format. quality
of 0
means compress for the smallest size. 100
means compress for max visual quality.
PNG
enum val PNG : Bitmap.CompressFormat
Compress to the PNG format. PNG is lossless, so quality
is ignored.
WEBP_LOSSLESS
enum val WEBP_LOSSLESS : Bitmap.CompressFormat
Compress to the WEBP lossless format. quality
refers to how much effort to put into compression. A value of 0
means to compress quickly, resulting in a relatively large file size. 100
means to spend more time compressing, resulting in a smaller file.
WEBP_LOSSY
enum val WEBP_LOSSY : Bitmap.CompressFormat
Compress to the WEBP lossy format. quality
of 0
means compress for the smallest size. 100
means compress for max visual quality.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Bitmap.CompressFormat\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nCompressFormat\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/graphics/Bitmap.CompressFormat \"View this page in Java\") \n\n```\nclass CompressFormat\n```\n\n|---|---|---------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||\n| ↳ | [kotlin.Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)\\\u003c[android.graphics.Bitmap.CompressFormat](#)\\\u003e ||\n| | ↳ | [android.graphics.Bitmap.CompressFormat](#) |\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [Bitmap.CompressFormat.JPEG](#ENUM_VALUE:JPEG), [Bitmap.CompressFormat.PNG](#ENUM_VALUE:PNG), [Bitmap.CompressFormat.WEBP](#ENUM_VALUE:WEBP), [Bitmap.CompressFormat.WEBP_LOSSLESS](#ENUM_VALUE:WEBP_LOSSLESS), [Bitmap.CompressFormat.WEBP_LOSSY](#ENUM_VALUE:WEBP_LOSSY) |------------------------------------------------------------------|---------------------------------------| | [Bitmap.CompressFormat.JPEG](#ENUM_VALUE:JPEG) | Compress to the JPEG format. | | [Bitmap.CompressFormat.PNG](#ENUM_VALUE:PNG) | Compress to the PNG format. | | [Bitmap.CompressFormat.WEBP](#ENUM_VALUE:WEBP) | Compress to the WEBP format. | | [Bitmap.CompressFormat.WEBP_LOSSLESS](#ENUM_VALUE:WEBP_LOSSLESS) | Compress to the WEBP lossless format. | | [Bitmap.CompressFormat.WEBP_LOSSY](#ENUM_VALUE:WEBP_LOSSY) | Compress to the WEBP lossy format. | |\n\nSpecifies the known formats a bitmap can be compressed into\n\nSummary\n-------\n\n| Enum values ||\n|----------------------------------------------------------------------------------|---|\n| [JPEG](#ENUM_VALUE:JPEG) Compress to the JPEG format. |\n| [PNG](#ENUM_VALUE:PNG) Compress to the PNG format. |\n| [WEBP](#ENUM_VALUE:WEBP) Compress to the WEBP format. |\n| [WEBP_LOSSLESS](#ENUM_VALUE:WEBP_LOSSLESS) Compress to the WEBP lossless format. |\n| [WEBP_LOSSY](#ENUM_VALUE:WEBP_LOSSY) Compress to the WEBP lossy format. |\n\nEnum values\n-----------\n\n### JPEG\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val JPEG : Bitmap.CompressFormat\n```\n\nCompress to the JPEG format. `quality` of `0` means compress for the smallest size. `100` means compress for max visual quality. \n\n### PNG\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val PNG : Bitmap.CompressFormat\n```\n\nCompress to the PNG format. PNG is lossless, so `quality` is ignored. \n\n### WEBP\n\nAdded in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val WEBP : Bitmap.CompressFormat\n```\n\n**Deprecated:** *in favor of the more explicit [CompressFormat.WEBP_LOSSY](#) and [CompressFormat.WEBP_LOSSLESS](#).*\n\nCompress to the WEBP format. `quality` of `0` means compress for the smallest size. `100` means compress for max visual quality. As of [android.os.Build.VERSION_CODES#Q](../os/Build.VERSION_CODES.html#Q:kotlin.Int), a value of `100` results in a file in the lossless WEBP format. Otherwise the file will be in the lossy WEBP format. \n\n### WEBP_LOSSLESS\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val WEBP_LOSSLESS : Bitmap.CompressFormat\n```\n\nCompress to the WEBP lossless format. `quality` refers to how much effort to put into compression. A value of `0` means to compress quickly, resulting in a relatively large file size. `100` means to spend more time compressing, resulting in a smaller file. \n\n### WEBP_LOSSY\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nenum val WEBP_LOSSY : Bitmap.CompressFormat\n```\n\nCompress to the WEBP lossy format. `quality` of `0` means compress for the smallest size. `100` means compress for max visual quality."]]