mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
check in quick fix to imagecache exception -- Max plz review
This commit is contained in:
@@ -76,13 +76,12 @@ public class ImageCache {
|
|||||||
rsKey.append("#").append(width).append('x').append(height);
|
rsKey.append("#").append(width).append('x').append(height);
|
||||||
String resizedKey = rsKey.toString();
|
String resizedKey = rsKey.toString();
|
||||||
|
|
||||||
|
|
||||||
final BufferedImage ready = CACHE.getIfPresent(resizedKey);
|
final BufferedImage ready = CACHE.getIfPresent(resizedKey);
|
||||||
if ( null != ready )
|
if (null != ready) {
|
||||||
return ready;
|
return ready;
|
||||||
|
}
|
||||||
|
|
||||||
BufferedImage original = getImage(key);
|
BufferedImage original = getImage(key);
|
||||||
//return original;
|
|
||||||
|
|
||||||
double scale = Math.min((double) width / original.getWidth(), (double) height / original.getHeight());
|
double scale = Math.min((double) width / original.getWidth(), (double) height / original.getHeight());
|
||||||
// here would be the place to limit the scaling option in menu ?
|
// here would be the place to limit the scaling option in menu ?
|
||||||
@@ -96,6 +95,12 @@ public class ImageCache {
|
|||||||
} else {
|
} else {
|
||||||
int destWidth = (int) (original.getWidth() * scale);
|
int destWidth = (int) (original.getWidth() * scale);
|
||||||
int destHeight = (int) (original.getHeight() * scale);
|
int destHeight = (int) (original.getHeight() * scale);
|
||||||
|
|
||||||
|
if (3 > width || 3 > height) {
|
||||||
|
// picture too small; return a blank
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
ResampleOp resampler = new ResampleOp(destWidth, destHeight);
|
ResampleOp resampler = new ResampleOp(destWidth, destHeight);
|
||||||
|
|
||||||
result = resampler.filter(original, null);
|
result = resampler.filter(original, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user