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 ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.