Game Development Reference
In-Depth Information
tagged image file format (TIFF) digital image formats. If you want to use digital image
formats other than GIF, JPEG, and PNG in your Java 8 games, import the third-party
ImageJ library.
Truecolor color depth images will feature 24-bit color depth and will thus contain
more than 16 million colors. This is calculated as 256 × 256 × 256 , which yields
16,777,216 colors. File formats supporting 24-bit color depth include JPEG (or JPG),
PNG, BMP, XCF, PSD, TGA, TIFF, and WebP. JavaFX supports three of these: JPG,
PNG24 (24 bit), and PNG32 (32 bit). Using 24-bit color depth will give you the highest
quality level. This is why I am recommending the use of PNG24 or PNG32 for your
Java games. Next, let's take a look at how to represent image pixel transparency values
through alpha channels and how these can be used for compositing digital imagery in
real time in Java 8 games!
Digital Image Compositing: Using Alpha Channels and
Transparency in Layers
Compositing is the process of seamlessly blending together multiple layers of digital
imagery. As you might imagine, this is an extremely important concept for game
design and development. Compositing is useful when you want to create an image on
the display that appears as though it is one single image (or animation), when it is actu-
ally the seamless collection of two or more composited image layers. One of the prin-
ciple reasons you would want to set up an image or animation composite is to allow
programmatic control over various elements in those images, by having them on differ-
ent layers.
To accomplish this, you need to have an alpha channel transparency value, which
you can use to control the precision of the blending amount of a given pixel with an-
other pixel (in the same x, y image location) on other layers (above and below it).
Like the other RGB channels, an alpha channel has 256 transparency levels . In
Java programming the alpha channel is represented by the first two slots in a hexa-
decimal representation of #AARRGGBB data values (which I will be covering in de-
tail in the next section). Alpha channel ARGB data values use eight slots (32 bit) of
data rather than the six data slots ( #RRGGBB ) used in a 24-bit image, which is really
a 32-bit image with zero alpha channel data.
Therefore, a 24-bit (PNG24) image has no alpha channel and will not be used for
compositing, unless it is the bottom image plate in a compositing layer stack. In con-
trast, PNG32 images will be used as compositing layers on top of PNG24 (background
plate) or PNG32 (lower, z-order compositing layers), which will need this alpha chan-
Search WWH ::




Custom Search