@@ -302,32 +302,41 @@ public Graphics2D checkImage() {
302302// image = new BufferedImage(width * pixelFactor, height * pixelFactor
303303// format == RGB ? BufferedImage.TYPE_INT_ARGB);
304304
305- GraphicsConfiguration gc = null ;
306- if (surface != null ) {
307- Component comp = null ; //surface.getComponent();
308- if (comp == null ) {
309- // System.out.println("component null, but parent.frame is " + parent.frame);
310- comp = parent .frame ;
311- }
312- if (comp != null ) {
313- gc = comp .getGraphicsConfiguration ();
314- }
315- }
316- // If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
317- if (gc == null ) {
318- //System.err.println("GraphicsConfiguration null in initImage()");
319- GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment ();
320- gc = ge .getDefaultScreenDevice ().getDefaultConfiguration ();
321- }
305+ // Commenting this out, because we are not drawing directly to the screen [jv 2018-06-01]
306+ //
307+ // GraphicsConfiguration gc = null;
308+ // if (surface != null) {
309+ // Component comp = null; //surface.getComponent();
310+ // if (comp == null) {
311+ //// System.out.println("component null, but parent.frame is " + parent.frame);
312+ // comp = parent.frame;
313+ // }
314+ // if (comp != null) {
315+ // gc = comp.getGraphicsConfiguration();
316+ // }
317+ // }
318+ // // If not realized (off-screen, i.e the Color Selector Tool), gc will be null.
319+ // if (gc == null) {
320+ // //System.err.println("GraphicsConfiguration null in initImage()");
321+ // GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
322+ // gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
323+ // }
322324
323325 // Formerly this was broken into separate versions based on offscreen or
324326 // not, but we may as well create a compatible image; it won't hurt, right?
327+ // P.S.: Three years later, I'm happy to report it did in fact hurt [jv 2018-06-01]
325328 int wide = width * pixelDensity ;
326329 int high = height * pixelDensity ;
327330// System.out.println("re-creating image");
328- image = gc .createCompatibleImage (wide , high , Transparency .TRANSLUCENT );
329- // image = gc.createCompatibleVolatileImage(wide, high);
330- //image = surface.getComponent().createImage(width, height);
331+
332+ // For now we expect non-premultiplied INT ARGB and the compatible image
333+ // might not be it... create the image directly. It's important that the
334+ // image has all four bands, otherwise we get garbage alpha during blending
335+ // (see https://github.com/processing/processing/pull/2645,
336+ // https://github.com/processing/processing/pull/3523)
337+ //
338+ // image = gc.createCompatibleImage(wide, high, Transparency.TRANSLUCENT);
339+ image = new BufferedImage (wide , high , BufferedImage .TYPE_INT_ARGB );
331340 }
332341 return (Graphics2D ) image .getGraphics ();
333342 }
0 commit comments