[ImagesTests PIC] Chapters 5-6.   Images, Visual Effects, and Animation

 

[ This topic is discussed over two chapters in the book. ]

Images are a central part of every game, and this chapter examines how we can (efficiently) load and display them, apply visual effects such as blurring, fading, and rotation, and animate them.

Image loading and processing is an area of Java which is undergoing rapid change, mainly driven by the wish for speed. We begin by reviewing the (rather outmoded) AWT imaging model, which is being superceded 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 JAI (Java Advanced Imaging) has even more capabilities.

The application developed in this chapter is called ImagesTests, shown as a thumbnail in the image above (click on it to see a full size version).

The static picture doesn't show the changing effects (animations) being applied to each image. Eleven different visual effects are used, including 'zapping', 'teleportation', and the more familiar reddening, blurring, and flipping.

The effects are mostly Java 2D operations, such as convolution or affine transformation. Occasionally, we make use of capabilities in drawImage() (e.g. for resizing and flipping an image).

The images (in GIF, JPEG, or PNG format) are loaded by our own ImagesLoader class from a JAR file containing the application and the images. The images are loaded using ImageIO's read(), and stored as BufferedImage objects, in order to take advantage of the JVM's "managed image" features.

ImagesLoader can load individual images, image strips, and multiple image files which represent an animation sequence.

The animation effects utilized by ImagesTests falls into two categories:

  1. those defined by repeatedly applying a visual effect, such as blurring, to the same image, but by an increasing amount;
  2. those where the animation is represented by a series of different images displayed one after another.
 

Downloads


Navigation:


Dr. Andrew Davison
E-mail: ad@fivedots.coe.psu.ac.th
Back to my home page