screenImage = new BufferedImage(
(int)(scale * bImage.getWidth()),
(int)(scale * bImage.getHeight()),
BufferedImage.TYPE_3BYTE_BGR );
AffineTransform transform = new AffineTransform();
transform.scale(scale, scale);
Graphics2D g = screenImage.createGraphics();
g.drawImage(bImage, transform, null);
imageComponent = new ImageComponent(screenImage, 640, 480);to create a second smaller image. The problem is - it doesn't inherit the same ColorModel so I tried
Raster raster = Raster.createBandedRaster(
DataBuffer.TYPE_BYTE,
(int)(scale * bImage.getWidth()),
(int)(scale * bImage.getHeight()),
bImage.getRaster().getNumBands(),
new Point());
WritableRaster writableRaster =
raster.createCompatibleWritableRaster();
screenImage = new BufferedImage(bImage.getColorModel(),
writableRaster, false, null);
AffineTransform transform = new AffineTransform();
transform.scale(scale, scale);
Graphics2D g = screenImage.createGraphics();
g.drawImage(bImage, transform, null);
imageComponent = new ImageComponent(screenImage, 640, 480);When I print out the image particulars not only is the ColorModel the same, but the imageType is custom like the original bImage as well. The problem is when I try to render screenImage on the display with drawImage() in imageComponent's print() method, I get the following exception thrown. Is there anything obviously wrong with the above code?
Cheers, Eric
P.S. Is there any documentation on what Properties can be passed in the BufferedImage constructor?
java.awt.image.ImagingOpException: Unable to transform src image
at java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:263)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:304)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:818)
at sun.java2d.pipe.ValidatePipe.transformImage(ValidatePipe.java:179)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2920)
at CinPrintFrame$ImageComponent.paint(CinPrintFrame.java:418)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:552)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4778)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4724)
at javax.swing.JComponent.paint(JComponent.java:798)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1309)
at sun.awt.RepaintArea.paint(RepaintArea.java:177)
at sun.awt.motif.MComponentPeer.handleEvent(MComponentPeer.java:374)
at java.awt.Component.dispatchEventImpl(Component.java:3658)
at java.awt.Container.dispatchEventImpl(Container.java:1623)
at java.awt.Window.dispatchEventImpl(Window.java:1585)
at java.awt.Component.dispatchEvent(Component.java:3439)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
