From 186ea1218ee5dcb7650d0759a2af4b61af166cbe Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Wed, 14 Mar 2018 13:26:47 -0400 Subject: [PATCH] Document the byte packing order of the current Bitmap.Configs This CL documents the byte order for 585, 8888, and fp16 buffers. Test: documenting existing behavior Bug: 71518511 Change-Id: I128344db318eb4597b6eb00f0ae317e369145152 --- graphics/java/android/graphics/Bitmap.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java index 44e7066c5c661..52d29e32e4642 100644 --- a/graphics/java/android/graphics/Bitmap.java +++ b/graphics/java/android/graphics/Bitmap.java @@ -461,6 +461,11 @@ public final class Bitmap implements Parcelable { * * This configuration may be useful when using opaque bitmaps * that do not require high color fidelity. + * + *

Use this formula to pack into 16 bits:

+ *
+         * short color = (R & 0x1f) << 11 | (G & 0x3f) << 5 | (B & 0x1f);
+         * 
*/ RGB_565 (3), @@ -493,6 +498,11 @@ public final class Bitmap implements Parcelable { * * This configuration is very flexible and offers the best * quality. It should be used whenever possible. + * + *

Use this formula to pack into 32 bits:

+ *
+         * int color = (A & 0xff) << 24 | (B & 0xff) << 16 | (G & 0xff) << 8 | (R & 0xff);
+         * 
*/ ARGB_8888 (5), @@ -503,6 +513,11 @@ public final class Bitmap implements Parcelable { * * This configuration is particularly suited for wide-gamut and * HDR content. + * + *

Use this formula to pack into 64 bits:

+ *
+         * long color = (A & 0xffff) << 48 | (B & 0xffff) << 32 | (G & 0xffff) << 16 | (R & 0xffff);
+         * 
*/ RGBA_F16 (6),