The ARGB_8888 configuration constant defines that the bitmap will be created with 8 bits of memory per color, 8 bits for the "A" or alpha channel, 8 bits for the "R" or red channel, 8 bits for the "G" or green channel, and 8 bits for the "B" or blue channel. This means that each pixel of the image will be represented by values between 0 and 255 for each color, including alpha. This means that each pixel will be represented by 32 bits and the total number of distinct colors that can be represented is more than 16.7 million.
Other configuration constants are available that use less memory and are therefore faster to process at the expense of image quality.
■ ALPHA_8: Used for Bitmaps that function as alpha masks, 8 bits on alpha channel only. No other colors.
■ ARGB_4444: 4 bits per color channel including alpha. Allows for 4096 unique colors with 16 alpha values. Figure 4-1 illustrates this setting using a rainbow gradient.
■ ARGB_8888: 8 bits per color channel including alpha. Allows for 16.7 million unique colors with 256 alpha values. Figure 4-2 illustrates this setting using a rainbow gradient.
■ RGB_565: 5 bits for the red channel, 6 bits for green, and 5 for blue (no alpha). Allows for 65,535 distinct colors. As Figure 4-3 illustrates, this setting is almost as high-quality as ARGB_8888 but takes up much less memory space.
Figure 4-1. Rainbow gradient displayed on Bitmap in ARGB_4444 mode; notice the banding in the dark blue to light blue and yellow to orange portions. ARGB_4444 can't represent the required colors to make those transitions smooth.
Was this article helpful?