O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scaling and Flipping Images

java.awt.Graphics provides several overloaded versions of drawImage(), which are listed in Table 7-1.

All of the methods are passed an image to draw and an image observer. If a method is passed a color, the color replaces any transparent bits in the image—the effect is as if the background of the image had been painted with the current background color and the image subsequently drawn over the background.

The integer values represent either a point in the image (source) or component (destination), or the width and height of the source and destination regions.

Figure 7-1 shows an application that exercises each of the methods listed in Table 7-1.

Figure 7-1. Scaling and Flipping Images. Overloaded Graphics.drawImage ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required