Java2D images crash after being resized (#2113)

This commit is contained in:
Ben Fry
2013-10-06 16:16:41 -04:00
parent e6d7ff653d
commit a581cc7550
2 changed files with 32 additions and 6 deletions
+16 -6
View File
@@ -1247,15 +1247,25 @@ public class PGraphicsJava2D extends PGraphics {
// Image not ready yet, or an error
if (who.width <= 0 || who.height <= 0) return;
if (getCache(who) == null) {
ImageCache cash = (ImageCache) getCache(who);
// Nuke the cache if the image was resized
if (cash != null) {
if (who.width != cash.image.getWidth() ||
who.height != cash.image.getHeight()) {
cash = null;
}
}
if (cash == null) {
//System.out.println("making new image cache");
this.setCache(who, new ImageCache(who));
cash = new ImageCache(who);
setCache(who, cash);
who.updatePixels(); // mark the whole thing for update
who.modified = true;
}
ImageCache cash = (ImageCache) getCache(who);
// if image previously was tinted, or the color changed
// If image previously was tinted, or the color changed
// or the image was tinted, and tint is now disabled
if ((tint && !cash.tinted) ||
(tint && (cash.tintedColor != tintColor)) ||
@@ -1273,8 +1283,8 @@ public class PGraphicsJava2D extends PGraphics {
(int) x1, (int) y1, (int) x2, (int) y2,
u1, v1, u2, v2, null);
// every few years I think "nah, Java2D couldn't possibly be that
// f*king slow, why are we doing this by hand? then comes the affirmation.
// Every few years I think "nah, Java2D couldn't possibly be that f*king
// slow, why are we doing this by hand?" then comes the affirmation:
// Composite oldComp = null;
// if (false && tint) {
// oldComp = g2.getComposite();
+16
View File
@@ -12,6 +12,20 @@ X http://stackoverflow.com/questions/10556875/list-of-unicode-characters-that-
X http://stackoverflow.com/questions/3072152/what-is-unicode-character-2028-ls-line-separator-used-for
X fix image transparency in PDF output
X https://github.com/processing/processing/pull/2070
X Java2D images crash after being resized
X https://github.com/processing/processing/issues/2113
opengl
X fix inconsistency with P2D and resetMatrix()
X https://github.com/processing/processing/issues/2087
X text rendering problems
X https://github.com/processing/processing/issues/2109
X textSize() not working properly in P2D
X https://github.com/processing/processing/issues/2073
X incorrectly applied transformations in retained mode
X https://github.com/processing/processing/issues/2097
X push/popStyle() causes color problems with P2D/P3D
X https://github.com/processing/processing/issues/2102
_ Sort out blending differences with P2D/P3D
_ https://github.com/processing/processing/issues/1844
@@ -19,6 +33,8 @@ _ 'collector' class.. Dict that points to a list
_ String as a key, int/float/string list as values
high
_ custom DPI settings with PDF
_ https://github.com/processing/processing/pull/2069
_ loadPixels doesn't set alpha value for pixels on Java2D
_ https://github.com/processing/processing/issues/2030
_ blendMode(ADD) is broken with default renderer