I am trying to rotate very small, square images (9 - 243 pixels wide) using a rotate
instance of AffineTransform with a translated pivot point (to center instead of
origin). The BufferedImage I begin with is "inPatternImage" and I show it's values in
some debug code (see below). I use an AffineTransformOp to give the rotated image to
a new BufferedImage and I lose pixels on the left side and top of the rotated image
(which would be the bottom and top left corners of the input image). I am rotating
clockwise. Here is a sample debug output for the input Image (8 bit values):
Attributes of inPatternImage:
BufferedImage@6265d0: type = 10 ColorModel: #pixelBits = 8 numComponents = 1
color space = java.awt.color.ICC_ColorSpace@a6e6e transparency = 1
has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 11
height = 11 #numDataElements 1 dataOff[0] = 0
MinX of inPatternImage is: 0
MinY of inPatternImage is: 0
VALUES OF inPatternImage (11 x 11 pixels):
64 64 64 64 64 96 160 160 96 64 64
64 64 64 64 64 96 160 160 96 64 64
64 64 64 64 64 96 160 160 128 64 64
64 64 64 64 64 96 160 160 128 96 64
64 64 64 64 64 128 160 160 128 96 96
64 64 64 64 96 128 128 160 128 128 128
64 64 64 64 64 96 128 192 192 160 160
64 64 64 64 64 96 128 192 160 128 96
64 64 64 64 64 96 128 160 160 96 64
64 64 64 64 64 96 128 160 160 128 96
64 64 64 64 96 128 192 224 192 128 64
And here is this image after rotation and assignment to another BufferedImage:
Attributes of rotated outPatternImage (-45 degree rotation):
BufferedImage@706da8: type = 2 DirectColorModel: rmask=ff0000 gmask=ff00
bmask=ff amask=ff000000 IntegerInterleavedRaster: width = 14 height = 14
#Bands = 4 xOff = 0 yOff = 0 dataOffset[0] 0
VALUES OF ROTATED IMAGE:
0 0 0 198 169 152 138 136 0 0 0 0 0 0
0 0 191 204 200 188 170 159 168 0 0 0 0 0
0 142 161 191 204 201 188 176 184 198 0 0 0 0
135 135 142 161 191 204 201 188 204 193 159 0 0 0
135 135 135 142 175 194 192 215 215 192 159 150 0 0
135 135 135 135 155 184 180 200 217 204 188 177 138 0
135 135 135 135 150 150 161 178 194 204 208 201 0 0
135 135 135 135 135 135 142 161 178 201 233 0 0 0
0 135 135 135 135 135 135 142 167 209 0 0 0 0
0 0 135 135 135 135 135 138 167 0 0 0 0 0
0 0 0 135 135 135 135 135 0 0 0 0 0 0
0 0 0 0 135 135 135 0 0 0 0 0 0 0
0 0 0 0 0 135 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0
inWidth = 5.5 (pivot point x)
inHeight = 5.5 (pivot point y)
outPatternImage (should be 15 x 15 by my calculations):
newWidth = 14
newHeight = 14
Here is a code fragment where this takes place:
//params are byte[], size
buf = new DataBufferByte(temp, patterns[INPUTS][patternNum].length );
//params are samplemodel, databuffer, Point(0,0)
raster = Raster.createRaster( model, buf, pt);
wraster = raster.createCompatibleWritableRaster();
inPatternImage = new BufferedImage( colorModel, wraster, true, null);
//parameters are x, y, width, height, int[]array
inPatternImage.getRaster().setPixels(0, 0, VLS.vls.originalFovealWidth,
VLS.vls.originalFovealWidth,
patterns[INPUTS][patternNum] );
//leave out a bunch of debug code
//create a rotation around the center coordinate (i.e. the sample) of
the pattern
//right now this does not work for foveal - or anything else!
inWidth = ( (double)inPatternImage.getWidth() )/2;
inHeight = ( (double)inPatternImage.getHeight() )/2;
ato = new AffineTransformOp(
AffineTransform.getRotateInstance(VLS.vls.rotateRadians, inWidth, inHeight),
AffineTransformOp.TYPE_BILINEAR );
outPatternImage = ato.createCompatibleDestImage( inPatternImage, null );
outPatternImage = ato.filter( inPatternImage, null );
//display the attribute values of the BufferedImage object, not the
pixel values
bw.write( "Attributes of rotated outPatternImage: \n" );
...
Thanks for any information you may offer about this.
cc
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".