From 2ea9758dc221092b8c2587d9a7710436f9539875 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Sat, 6 Aug 2016 15:23:08 +0200 Subject: [PATCH] Fix resizing targets for async save Got burned by not setting pixelWidth and pixelHeight properly. Fixes #4578 --- core/src/processing/core/PGraphics.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index c7606c7ac..9b2e18cdb 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -8364,12 +8364,10 @@ public class PGraphics extends PImage implements PConstants { targetsCreated++; } else { target = targetPool.take(); - if (target.width != requestedWidth || - target.height != requestedHeight) { - target.width = requestedWidth; - target.height = requestedHeight; + if (target.pixelWidth != requestedWidth || + target.pixelHeight != requestedHeight) { // TODO: this kills performance when saving different sizes - target.pixels = new int[requestedWidth * requestedHeight]; + target = new PImage(requestedWidth, requestedHeight); } } target.format = format;