Hi, I originally posted this message in the SwingX forum and they suggested I post that in Java2D as well: http://forums.java.net/jive/thread.jspa?threadID=42577&tstart=0. This happens on Windows XP 32-bits, nVidia GeForce 7600, JDK 1.5.0_10 and 1.6.0_10 beta.
----------------------------------------------------------------------------- Hi, I've been experiencing lately with SwingX and made a quick mockup of a Vista/Windows Media Player-like button using Painters and JXButtons. At some point I compose an image containing a gaussian blurred oval using BlendComposite.ColorDodge in order to make a halo/higlight at the base of the button. However, I've come to an issue when drawImage() is called on a Graphics after both setClip() and setComposite(BlendComposite.whatever) have been set. This happens with both SwingX 0.9.2 and 0.9.3. Here is a small exemple that demonstrate the issue: [code] import java.awt.geom.*; import javax.swing.*; /** * <p>Title: </p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2006</p> * * <p>Company: </p> * * @author not attributable * @version 1.0 */ class TestClip extends JPanel { private BufferedImage image; private int width = 320; private int height = 200; public TestClip() { super(); setPreferredSize(new Dimension(width, height)); } @Override protected void paintComponent(Graphics g) { if (image == null) { BufferedImage clipped = getGraphicsConfiguration().createCompatibleImage(width, height, Transparency.OPAQUE); Graphics2D g2d = clipped.createGraphics(); g2d.setColor(Color.RED); g2d.fillRect(0, 0, width, height); g2d.dispose(); // image = getGraphicsConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); g2d = image.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); RoundRectangle2D clip = new RoundRectangle2D.Float(10, 10, width -20 - 1, height -20 - 1, 10, 10); g2d.setClip(clip); g2d.setComposite(org.jdesktop.swingx.graphics.BlendComposite.ColorDodge); //g2d.setComposite(AlphaComposite.SrcOver); g2d.drawImage(clipped, 0, 0, null); //g2d.setColor(Color.RED); //g2d.fillRect(0, 0, width, height); g2d.setComposite(AlphaComposite.SrcOver); g2d.setClip(null); g2d.setStroke(new BasicStroke(1f)); g2d.setColor(Color.BLACK); g2d.draw(clip); g2d.dispose(); } g.drawImage(image, 0, 0, null); } public static void main(String ...args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new TestClip(), BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } }); } } [/code] This code produces the following error: [code] Exception in thread "AWT-EventQueue-0" java.awt.image.RasterFormatException: (x + width) is outside raster at sun.awt.image.IntegerInterleavedRaster.createWritableChild(Unknown Source) at sun.awt.image.IntegerInterleavedRaster.createChild(Unknown Source) at sun.java2d.loops.Blit$AnyBlit.Blit(Unknown Source) at sun.java2d.pipe.DrawImage.blitSurfaceData(Unknown Source) at sun.java2d.pipe.DrawImage.renderImageCopy(Unknown Source) at sun.java2d.pipe.DrawImage.copyImage(Unknown Source) at sun.java2d.pipe.DrawImage.copyImage(Unknown Source) at sun.java2d.pipe.ValidatePipe.copyImage(Unknown Source) at sun.java2d.SunGraphics2D.drawImage(Unknown Source) at sun.java2d.SunGraphics2D.drawImage(Unknown Source) at test.TestClip.paintComponent(TestClip.java:46) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JLayeredPane.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paintToOffscreen(Unknown Source) at javax.swing.BufferStrategyPaintManager.paint(Unknown Source) at javax.swing.RepaintManager.paint(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) at sun.awt.SunGraphicsCallback.runComponents(Unknown Source) at java.awt.Container.paint(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.seqPaintDirtyRegions(Unknown Source) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) [/code] Line 46 is the drawImage() line. If I use a standard AlphaComposite no error happens of course, if I stick with a BlendComposite, comment drawImage() and uncomment the red rectangle rendering instead everything is fine as well. I find this error quite strange, though I can avoid it in my button scenario by clipping directly the 2nd image (the one that contains the oval) itself after the blur and clearing its areas that are outside of the button's shape; then reseting the clip of the painter to its default value, compositing the image onto the painter with BlendComposite.ColorDodge and finally resetting the clip of the painter to the working clip. [Message sent by forum member 'bouye' (bouye)] http://forums.java.net/jive/thread.jspa?messageID=281507 =========================================================================== 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".