304 CHAPTER 9: Android Graphic Design: Making Your UI Designs Visual
Coloring Your Digital Images: RGB Color Theory
So now you understand digital image pixels, and how they’re arranged using 2D rectangular arrays,
at a specific aspect ratio which defines their rectangular shape! The next logical aspect (again, no
pun intended) to look into is how each of those pixels assign their color values. Color values for
pixels are defined by the amount of three colors, red, green, and blue (hence the term RGB), which
are present in varying amounts in each pixel. Android display screens utilize additive color, which is
where the wavelengths of light for each RGB color plane are summed together. Additive color can
be used to create tens of millions of different color values, and is utilized in the popular LED displays
used in iTVs, smartphones, laptops and tablets. Additive color is the opposite of subtractive color,
which is utilized in printers.
To show the difference, under a subtractive color model, mixing a red color with a green (using inks)
will yield a purple color, whereas in an additive color model, mixing a red color with a green color
(using light) will yield a yellow color. Subtractive color models are limited in the spectrum of color
that they can produce, whereas the additive color model can produce every color under the rainbow
(or, I should say, every color in the universe!).
The amount, or numbers, of red, green, and blue “shades” or intensities of light that you have
available to mix together will determine the total amount of colors which you will be able to
reproduce. In today’s digital device hardware capabilities, we can produce eight bits (8-bit) or
256 levels of light intensity for each red, green, and blue (RGB) color.
We can generate this color for each pixel individually, so every pixel in your image can have 256
levels of color intensity variation, for each of these red, green, and blue values. Each of these RGB
“plates” or “planes” will use one byte of data per red, green, and blue color. A byte uses an 8-bit
data value, which allows it to represent the color intensity level from a minimum of zero (off, no
color contributed, or black if all the RGB planes are using this value) to a maximum of 255 (fully on,
maximum color contributed, or white if all RGB planes are using this value).
The Number of Colors in a Digital Image: Color Depth
The number of data bits which are used to represent the amount or number of colors in a digital
image is referred to as the color depth of that image. It is important to note that in digital imaging,
less than 8 bits can be used to represent the amount of colors in an image, but only when you are
using an indexed color model, which we’ll be learning about soon.
There are several common color depth levels used in the digital imaging industry, and I will outline
the most common ones here, along with the digital image file formats used with each color depth in
the Android OS. The lowest color depth exists using the 8-bit indexed color digital image format.
An indexed color image will have a maximum of 256 total color values per pixel and will use the GIF
and PNG8 image formats to contain this indexed color type of digital image data. An indexed color
image will not have three (RGB) color planes, so it is generally three times smaller than a truecolor
RGB image. Instead of the three (RGB) color planes, indexed color uses a “palette” of up to 256
color values to represent all of the colors in the digital image.