Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 2 ■ an IntroduCtIon to Content CreatIon: 2d new MedIa asset FundaMentals


On the left side of GIMP you can see Alpha layer, which I selected in blue. This contains the
transparency values for the MindTaffy logo. The GIMP Channels palette, which is the tab that I selected
to show you these color and alpha channels (Red, Green, Blue, Alpha), holds these color (and alpha)
channels separately for each layer, allowing you an incredible level of control over each pixel in each image
composite layer.
Like the other RGB channels, an alpha channel has 256 levels, but instead of red, green, or blue, these
values are transparency levels. In Java programming, the alpha channel is represented by the first two slots
in a hexadecimal representation delineated in the format #AARRGGBB data value. We will be covering
this in detail in the next section. Alpha plus color channel ARGB data values utilize eight slots (32-bit) of
data, rather than the six data slots (#RRGGBB) used in a 24-bit image, which could be thought of as a 32-bit
image with zero (no) alpha channel data.
Therefore, a 24-bit (PNG24) image has no alpha channel and will not be used for compositing, unless
it’s the background (bottom) image plate in your compositing layer stack. On the other hand, PNG32
imagery will be used as compositing layers on top of a PNG24 (background plate) image, or on top of lower
z-order PNG32 compositing layers that will need their alpha channel capability in order to show through,
via these alpha channel transparency values, in certain pixel locations in the image composite where some
measure of transparency (or opacity) is required.
How do digital image alpha channels, and the concept of image compositing, factor into Java Game
Design? You must be wondering! The primary advantage is an ability to break the gameplay screen, and the
sprites, projectiles, and background graphic elements that it includes, into a number of component layers.
The reason for doing this is to be able to apply Java programming logic (or JavaFX or SVG special effects) to


Figure 2-2. Showing the checkerboard representation of transparent pixels in an image, as well as the RGBA
channels

Free download pdf