I am trying to render a 1bpp image but I am having many problem swith
that:
***********************************************************************
First problem:
When I cast Graphics g to Graphics2D the compiler crashes with a
ClassCastException if the Graphics is above a Swing component as JPanel.
I have tried to place the Graphics above a AWT component as Panel and it
works fine.
I know that is the java bug ID 4100676. However in the bug report in Sun
pages they say that the bug has been fixed and closed in release
1.2beta4, but in the release 1.2.2, which I am using, is crashing, (at
least for me).
Am I wrong or are they wrong??
***********************************************************************
Second problem:
I am trying to draw the 1bpp BufferedImage that I have created as:
<pre>
byte[] pixmap = new byte[] {(byte)255, (byte)0};
IndexColorModel ColorModel = new IndexColorModel(1, 2, pixmap,
pixmap, pixmap);
WritableRaster raster = Raster.createPackedRaster(new
DataBufferByte(VpaGetBMP(),
VpaGetBMPSize()), ((w+31)/32)*32, h, 1,
null;
BufferedImage img = new BufferedImage(ColorModel, raster, false,
null);
</pre>
When I try to render without transformation the rendering is fine:
g2.drawImage(img, null, clip.x, clip.y);
however when I try to fit the image in a region of the screen:
g2.drawImage(img, clip.x, clip.y, clip.x+clip.width,
clip.y+clip.height, // destination
xSrc, ySrc, xSrc + wSrc, ySrc +
hSrc, // source location
this);
the compiler crashes with the following message:
Exception occurred during event dispatching:
java.lang.IllegalArgumentException: Raster BytePackedRaster: width = 422
height = 596 #channels 1 xOff = 0 yOff = 0 is incompatible with
ColorModel IndexColorModel: #pixelBits = 1 numComponents = 4 color space
= java.awt.color.ICC_ColorSpace@73fe6802 transparency = 2 transIndex =
2 has alpha = true isAlphaPre = false
at sun.java2d.SunGraphics2D.renderingPipeImage(SunGraphics2D.java,
Compiled Code)
I tried by scaling by hand with AffineTransform classes but the same
occurs.
By changing the color model definition to:
IndexColorModel ColorModel = new IndexColorModel(8, 2, pixmap, pixmap,
pixmap);
as Sun engineers advice again works fine again when I just render the
image, but throws this compilation error when I try to render scaling
(with drawImage method or with AffinaTransform) the image:
Exception occurred during event dispatching:
java.awt.image.ImagingOpException: Unable to transform src image
at java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:236)
*****************************************************************
I am using release 1.2.2. I would like to know if these issues are fixed
in version 1.2.2 or following versions and the best workarounds
availables. Any experience would be also appreciated.
Many thanks in advance,
Adolfo Rodriguez.
===========================================================================
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".