@@ -1247,15 +1247,25 @@ protected void imageImpl(PImage who,
12471247 // Image not ready yet, or an error
12481248 if (who .width <= 0 || who .height <= 0 ) return ;
12491249
1250- if (getCache (who ) == null ) {
1250+ ImageCache cash = (ImageCache ) getCache (who );
1251+
1252+ // Nuke the cache if the image was resized
1253+ if (cash != null ) {
1254+ if (who .width != cash .image .getWidth () ||
1255+ who .height != cash .image .getHeight ()) {
1256+ cash = null ;
1257+ }
1258+ }
1259+
1260+ if (cash == null ) {
12511261 //System.out.println("making new image cache");
1252- this .setCache (who , new ImageCache (who ));
1262+ cash = new ImageCache (who );
1263+ setCache (who , cash );
12531264 who .updatePixels (); // mark the whole thing for update
12541265 who .modified = true ;
12551266 }
12561267
1257- ImageCache cash = (ImageCache ) getCache (who );
1258- // if image previously was tinted, or the color changed
1268+ // If image previously was tinted, or the color changed
12591269 // or the image was tinted, and tint is now disabled
12601270 if ((tint && !cash .tinted ) ||
12611271 (tint && (cash .tintedColor != tintColor )) ||
@@ -1273,8 +1283,8 @@ protected void imageImpl(PImage who,
12731283 (int ) x1 , (int ) y1 , (int ) x2 , (int ) y2 ,
12741284 u1 , v1 , u2 , v2 , null );
12751285
1276- // every few years I think "nah, Java2D couldn't possibly be that
1277- // f*king slow, why are we doing this by hand? then comes the affirmation.
1286+ // Every few years I think "nah, Java2D couldn't possibly be that f*king
1287+ // slow, why are we doing this by hand?" then comes the affirmation:
12781288// Composite oldComp = null;
12791289// if (false && tint) {
12801290// oldComp = g2.getComposite();
0 commit comments