Hello Dmitri,
I was able to extract a tiny test case that reproduces the bug. The
error only seems to occur when an image is streched, not when it is
painted in the original size. As you can see the composite does nothing
in the test case, but I think the error happens even before the
composite context is actually used.
Here is the test case:
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
/**
* Class to reproduce a bug (?) with custom composites
*
* JRE 1.6 b72 throw as java.lang.InternalError: Cannot construct
general op for MaskBlit(...) Any CompositeContext
*/
public class CompositeBugTest {
public static void main(String[] args) {
JFrame frame = new JFrame("Composite Test");
frame.setContentPane(new JPanelImage());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.validate();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private static class JPanelImage extends JPanel {
private Image image = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
public JPanelImage() {
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (g instanceof Graphics2D) {
Graphics2D g2D = (Graphics2D) g;
g2D.setComposite(new TestComposite());
// using drawImage(image, 0, 0, null) works without problems
g2D.drawImage(image, 0, 0, 200, 200, null);
} else {
assert false;
}
}
}
private static class TestComposite implements Composite {
public CompositeContext createContext(ColorModel srcColorModel,
ColorModel dstColorModel, RenderingHints hints) {
return new TestCompositeContext();
}
}
private static class TestCompositeContext implements CompositeContext {
public void compose(Raster src1, Raster src2, WritableRaster dstOut) {
}
public void dispose() {
}
}
}
I am using WinXP on an IBM ThinkPad (ATI graphics card). If you need
more details, please let me know.
Cheers
Jan
Dmitri Trembovetski wrote:
Hello Jan,
this is interesting. It looks very much like bug
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4445611
which was supposedly fixed in 1.4.
Could you extract and send over a simplified test that reproduces
the error?
Thanks,
Dmitri
On Fri, Feb 17, 2006 at 11:04:57AM +0100, "Jan B?senberg (INCORS GmbH)" wrote:
> I have run into an issue with some code that is a bit difficult for me
> to understand (because it was programmed by someone else who did not
> like commenting very much). Maybe someone can push me in the right
> direction to get a better understanding of this issue.
>
> In the code a custom composite is set for a Graphics2D object using the
> setComposite(...) method. After the drawImage(...) method gets called I
> see this InternalError:
>
> Exception in thread "AWT-EventQueue-0" java.lang.InternalError: Cannot
> construct general op for MaskBlit(...) Any CompositeContext
> at
>
sun.java2d.loops.GraphicsPrimitive.setupGeneralBinaryOp(GraphicsPrimitive.java:476)
> at sun.java2d.loops.MaskBlit.makePrimitive(MaskBlit.java:115)
> at
> sun.java2d.loops.GraphicsPrimitiveMgr.locate(GraphicsPrimitiveMgr.java:142)
> at sun.java2d.loops.MaskBlit.locate(MaskBlit.java:43)
> at sun.java2d.loops.MaskBlit.getFromCache(MaskBlit.java:56)
> at sun.java2d.pipe.DrawImage.renderImageXform(DrawImage.java:428)
> at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:251)
> at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:715)
> at sun.java2d.pipe.DrawImage.scaleImage(DrawImage.java:1012)
> at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:201)
> at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3057)
> at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3006)
> at (our code)
>
>
> The Error occurs with JRE 1.6 b72 (and a bunch of previous releases).
> With JRE 1.5 this error did not occur, but a black rectangle gets
> painted. This is probably not the desired effect, either, but as I said,
> I have difficulties in understanding what exactly is happening.
>
> Is this InternalError a known bug? Do you think it is caused by our code
> (maybe in the custom composite) or is this rather a bug in the JDK? Any
> help is appreciated.
>
>
> Thanks
>
> Jan
>
> ===========================================================================
> 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".
===========================================================================
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".