Skip to content

Instantly share code, notes, and snippets.

@ErikHellman
Last active August 8, 2019 08:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErikHellman/7767188ef6ddbab1a6d134888e5fc4f0 to your computer and use it in GitHub Desktop.
Save ErikHellman/7767188ef6ddbab1a6d134888e5fc4f0 to your computer and use it in GitHub Desktop.
Kotlin functions for getting the name of an ImageFormat or PixelFormat Integer.
fun imageFormatName(format: Int): String = when (format) {
ImageFormat.DEPTH16 -> "DEPTH16"
ImageFormat.DEPTH_JPEG -> "DEPTH_JPEG"
ImageFormat.DEPTH_POINT_CLOUD -> "DEPTH_POINT_CLOUD"
ImageFormat.FLEX_RGBA_8888 -> "FLEX_RGBA_8888"
ImageFormat.FLEX_RGB_888 -> "FLEX_RGB_888"
ImageFormat.HEIC -> "HEIC"
ImageFormat.JPEG -> "JPEG"
ImageFormat.NV16 -> "NV16"
ImageFormat.NV21 -> "NV21"
ImageFormat.PRIVATE -> "PRIVATE"
ImageFormat.RAW10 -> "RAW10"
ImageFormat.RAW12 -> "RAW12"
ImageFormat.RAW_PRIVATE -> "RAW_PRIVATE"
ImageFormat.RAW_SENSOR -> "RAW_SENSOR"
ImageFormat.RGB_565 -> "RGB_565"
ImageFormat.UNKNOWN -> "UNKNOWN"
ImageFormat.Y8 -> "Y8"
ImageFormat.YUV_420_888 -> "YUV_420_888"
ImageFormat.YUV_422_888 -> "YUV_422_888"
ImageFormat.YUV_444_888 -> "YUV_444_888"
ImageFormat.YUY2 -> "YUY2"
ImageFormat.YV12 -> "YV12"
else -> "Unknown"
}
@Suppress("DEPRECATION")
fun pixelFormatName(format: Int): String = when(format) {
PixelFormat.A_8 -> "A_8"
PixelFormat.JPEG -> "JPEG"
PixelFormat.LA_88 -> "LA_88"
PixelFormat.L_8 -> "L_8"
PixelFormat.OPAQUE -> "OPAQUE"
PixelFormat.RGBA_1010102 -> "RGBA_1010102"
PixelFormat.RGBA_4444 -> "RGBA_4444"
PixelFormat.RGBA_5551 -> "RGBA_5551"
PixelFormat.RGBA_8888 -> "RGBA_8888"
PixelFormat.RGBA_F16 -> "RGBA_F16"
PixelFormat.RGBX_8888 -> "RGBX_8888"
PixelFormat.RGB_332 -> "RGB_332"
PixelFormat.RGB_565 -> "RGB_565"
PixelFormat.RGB_888 -> "RGB_888"
PixelFormat.TRANSLUCENT -> "TRANSLUCENT"
PixelFormat.TRANSPARENT -> "TRANSPARENT"
PixelFormat.UNKNOWN -> "UNKNOWN"
PixelFormat.YCbCr_420_SP -> "YCbCr_420_SP"
PixelFormat.YCbCr_422_I -> "YCbCr_422_I"
PixelFormat.YCbCr_422_SP -> "YCbCr_422_SP"
else -> "Unknown"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment