Java Reference
In-Depth Information
TRANS_MIRROR_ROT180
TRANS_MIRROR_ROT270
The ROT transformations rotate the source image region by 90, 180, or 270 degrees. The
MIRROR_ROT transformations first mirror the region around its vertical center, and then rotate
the mirrored region.
The drawRegion() method allows easy manipulation and display of animation frames that
are packed into a single image.
Images As Integer Arrays
You've already seen how a single color can be represented as an integer. By extension, an
image can be represented as an array of integers, where each integer in the array contains the
color for a single pixel in the image.
Rendering integer arrays as images is supported with the following method:
public void drawRGB(int[] rgbData, int offset, int scanlength,
int x, int y, int width, int height,
boolean processAlpha)
The image data is contained in the rgbData array, starting at offset . Consecutive rows of
data are contained at offsets measured by multiples of scanlength . The image will be rendered
at x and y with a size defined by width and height .
The relationship between width and scanlength is a little confusing at first. The following
example should clear things up.
Consider the following code.
int[] rgbData = {
0x123456, 0x123456, 0x123456,
0x000000, 0xffffff, 0xffffff, 0x000000, 0x654321, 0x654321,
0x000000, 0x000000, 0xffffff, 0x000000, 0x654321, 0x654321,
0x000000, 0xffffff, 0x000000, 0x000000, 0x654321, 0x654321,
0x000000, 0xffffff, 0xffffff, 0x000000, 0x654321, 0x654321
};
g.drawRGB(rgbData, 3, 6, 10, 10, 4, 4, false);
This code produces the very small image shown at great magnification in Figure 13-8. The
first three elements of the array are ignored by passing an offset of 3. Although the image
width is 4 pixels, each row of data is separated by 6 positions in the integer array. The image will
be rendered at 10 , 10 , with a size of 4 by 4 pixels.
Figure 13-8. A very small image
Search WWH ::




Custom Search