transform image

hey there :slight_smile:

self-explaining, I guess :stuck_out_tongue:

AffineTransform[[2.0, 0.0, 382.0], [0.0, 2.0, 195.0]]


Exception in thread "Thread-2" java.awt.image.ImagingOpException: Unable to transform src image
      at java.awt.image.AffineTransformOp.filter(Unknown Source)
      at sun.java2d.pipe.DrawImage.renderImageXform(Unknown Source)
      at sun.java2d.pipe.DrawImage.transformImage(Unknown Source)
      at sun.java2d.pipe.DrawImage.transformImage(Unknown Source)
      at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
      at core.Display$subdisplay.draw(Display.java:199)
      at core.Display.draw(Display.java:78)

AffineTransform[[1.0, 0.0, 382.0], [0.0, 1.0, 195.0]] works fine, though…

any ideas? as soon as m00, m10, m01, or m11 are non-default, I get this error :frowning:

viewed 55 times and no idea? It still refuses to do anything else than translating coordinates, whenever I try to get it to shear or rotate any image it gives that very same error. I don’t need this now, but sooner or later I’m bound to need it, and I’ve really ran out of ideas what could be causing this :frowning:

Platform, jdk version, source/destination image types?

It could be one of the manifestations of
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4723021

Thanks,
Dmitri
Java2D Team

oh, right, I should have given more info… :stuck_out_tongue:

win2ksp4, jre1.5.0 (which is not reported to have that bug), source image is built like this:


palette = new IndexColorModel(8, 256, palR, palG, palB, 0);

imageData = new byte[imageBytes];

model = new MultiPixelPackedSampleModel(DataBufferInt.TYPE_BYTE, this.pcxwidth, this.pcxheight, 8);
buffer = new DataBufferByte(imageData, imageBytes);
raster = WritableRaster.createWritableRaster(model, buffer, zeropoint);

new BufferedImage(palette, raster, false, null);

the transform can be any with non-null shear or scale values:


AffineTransform gt = new AffineTransform();
gt.translate (0, bi.getHeight());
gt.scale (1, -1d);
g.transform (gt);
g.drawImage (image, null, null);

the flipping destination image is the code from the jumping into jogl tutorial (I think that’s what it was called), to get a drawPixels() compatible raster


raster = Raster.createInterleavedRaster (DataBuffer.TYPE_BYTE, bi.getWidth(), bi.getHeight(), 4, null);

colorModel= new ComponentColorModel (ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] {8,8,8,8}, true, false, ComponentColorModel.TRANSLUCENT, DataBuffer.TYPE_BYTE);

new BufferedImage (colorModel,
raster, false, null);

heh, seems to be more or less the same as in the bug report… tries the workaround

\ edit

forgot to mention, it’s the same problem if srcImg == dstImg


Graphics2D g = bi.createGraphics();

AffineTransform gt = new AffineTransform();
gt.translate (0, bi.getHeight());
gt.scale (1, -1d);
g.transform (gt);
g.drawImage(bi, null, null);

or


g.drawImage(bi, gt, null);

ummm… what the heck? You’re drawing the image onto itself.

Graphics2D g = bi.createGraphics();
g.drawImage(bi, gt, null);

Is that even possible?

don’t know, but guess yes, the transforming needs to be done with a copy of the raster anyways, so why not?

but that doesn’t really matter, as the error message is the same if I draw it to another image >_>