provided by: 
Originally published at Internet.com
Java Programming Notes # 454 * Preface * General Background Information * Preview * Discussion and Sample Code * Scaling * Translation * Rotation * Mirror Image * Run the Program * Summary * What's Next? * References * Complete Program Listing -----------------------------------
Preface
Part of a series
In an earlier lesson entitled A Framework for Experimenting with Java 2D Image-Processing Filters, I taught you how to write a framework program that makes it easy to use the image-filtering classes of the Java 2D API to process the pixels in an image and to display the processed image.
In the previous lesson entitled Using the Java 2D LookupOp Filter Class to Process Images, I taught you how to write programs that use the LookupOp image-filtering class of the Java 2D API for a variety of image-processing purposes.
At the close of that lesson, I told you that future lessons would teach you how to use the following image-filtering classes from the Java 2D API: * AffineTransformOp * BandCombineOp * ConvolveOp * RescaleOp * ColorConvertOp
In this lesson, I will keep that promise and teach you how to use the AffineTransformOp image-filtering class to perform a variety of transformations on images. I will teach you how to use the remaining classes from the above list in future lessons.
Viewing tip
You may find it useful to open another copy of this lesson in a separate browser window. That will make it easier for you to scroll back and forth among the different listings and figures while you are reading about them.
Supplementary material
I recommend that you also study the other lessons in my extensive collection of online Java tutorials. You will find those lessons published at Gamelan.com. However, as of the date of this writing, Gamelan doesn't maintain a consolidated index of my Java tutorial lessons, and sometimes they are difficult to locate there. You will find a consolidated index at www.DickBaldwin.com.
I also recommend that you pay particular attention to the lessons listed in the References section of this document.
General Background Information
Constructing images
Before getting into the programming details, it may be useful for you to review the concept of how images are constructed, stored, transported, and rendered in Java (and in most modern computer environments for that matter).
I provided a great deal of information on those topics in the earlier lesson entitled Processing Image Pixels using Java, Getting Started. Therefore, I won't repeat that information here. Rather, I will simply refer you back to the earlier lesson.
The framework program named ImgMod05
It will also be useful for you to understand the behavior of the framework program named ImgMod05. Therefore, I strongly recommend that you study the earlier lesson entitled A Framework for Experimenting with Java 2D Image-Processing Filters.
However, if you don't have the time to do that, I can summarize that framework program as follows:
Purpose of ImgMod05
The purpose of ImgMod05 is to make it easy for you to experiment with the modification of images using the image-filtering classes of the Java 2D API and to display the modified version of the image along with the original image. (See an example of the graphic output format in Figure 5.)
The Replot button
The ImgMod05 program GUI contains a Replot button (as shown in Figure 5). At the beginning of the run, and each time thereafter that the Replot button is clicked: * The image-processing method belonging to an object of specified image-processing class is invoked. * The original image is passed to the image-processing method, which returns a reference to a processed image. * The resulting processed image is displayed along with the original image. * The processed image is written into an output JPEG file named junk.jpg.
Display of the images
When the ImgMod05 program is started, the original image and the processed version of the image are displayed in a frame with the original image above the processed image (as shown in Figure 5). The program attempts to set the size of the display so as to accommodate both images. If both images are not totally visible, the user can manually resize the display frame.
Input and output file format
The ImgMod05 program will read gif and jpg input files and possibly some other input file types as well. The output file is always a JPEG file.
Typical usage
Enter the following at the command-line to run the ImgMod05 program: java ImgMod05 ProcessingProgramName ImageFileName
Preview
In this lesson, I will present and explain an image-processing program named ImgMod40 that is compatible with the framework program named ImgMod05. This program provides a GUI that allows the user to perform the following transforms on an input image: * Scaling * Translation * Rotation * Mirror Image
With the exception of the Mirror Image transform, all of the transforms in the above list allow the user to input important parameters via the GUI.
The program GUI is a JTabbedPane with four pages. Let's begin by taking a look at each of those pages.
Scaling
The Scaling page of the GUI is shown in Figure 1.
Author: Richard G. Baldwin
Read article at Internet.com site