Skip to Main Content
Killer Game Programming in Java
book

Killer Game Programming in Java

by Andrew Davison
May 2005
Intermediate to advanced content levelIntermediate to advanced
998 pages
26h
English
O'Reilly Media, Inc.
Content preview from Killer Game Programming in Java

Chapter 5. An Introduction to Java Imaging

This chapter presents an overview of image loading and processing in Java, areas that have seen major changes in recent releases of the SDK, mainly driven by the wish for speed. It's principally about introducing concepts that are illustrated in more detail in Chapter 6.

I begin by reviewing the (rather outmoded) AWT imaging model, which is being superseded by the BufferedImage and VolatileImage classes, ImageIO, and the wide range of BufferedImageOp image operations offered by Java 2D. If these aren't enough, then Java Advanced Imaging (JAI) has even more capabilities.

Many of the topics discussed here are utilized in Chapter 6, where I develop a ImagesLoader class. It loads images from a Java ARchive (JAR) file using ImageIO's read() and holds them as BufferedImage objects.

Tip

Chapter 6 utilizes ImagesLoader in an ImagesTests application, which demonstrates 11 different visual effects, including zapping, teleportation, reddening, blurring, and flipping. The effects are derived from Java 2D operations, such as convolution and affine transformation.

Image Formats

A game will typically use a mix of the GIF, JPEG, and PNG images, popular graphics formats that have advantages and disadvantages.

A Graphics Interchange Format (GIF) image is best for cartoon-style graphics using few colors, since only a maximum of 256 colors can be represented in a file. This is due to GIF's use of a 256-element color table to store information.

Tip

One of these color ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Game Development with LibGDX: From Beginner to Professional

Java Game Development with LibGDX: From Beginner to Professional

Lee Stemkoski

Publisher Resources

ISBN: 0596007302Supplemental ContentErrata Page