From 645068ddf63948fe870e251c080f8705a37961db Mon Sep 17 00:00:00 2001 From: AmnonOwed Date: Wed, 22 Jan 2014 21:14:11 +0100 Subject: [PATCH] Ensure RGB pixels are fully opaque --- core/src/processing/core/PImage.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/processing/core/PImage.java b/core/src/processing/core/PImage.java index 430d67228..ed17683d7 100644 --- a/core/src/processing/core/PImage.java +++ b/core/src/processing/core/PImage.java @@ -283,10 +283,14 @@ public class PImage implements PConstants, Cloneable { width = bi.getWidth(); height = bi.getHeight(); pixels = new int[width * height]; - WritableRaster raster = bi.getRaster(); - raster.getDataElements(0, 0, width, height, pixels); - if (bi.getType() == BufferedImage.TYPE_INT_ARGB) { + pixels = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData(); + int type = bi.getType(); + if (type == BufferedImage.TYPE_INT_ARGB) { format = ARGB; + } else if (type == BufferedImage.TYPE_INT_RGB) { + for (int i = 0; i < pixels.length; i++) { + pixels[i] = (255 << 24) | pixels[i]; + } } } else { // go the old school java 1.0 route