mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Load croped image from Wizard images. fixes display issue
When resizing image to fit the BigCard panel, scale it to fit width. The result is better.
This commit is contained in:
parent
f539d9d5ec
commit
1f72804968
11 changed files with 53 additions and 46 deletions
|
|
@ -19,6 +19,7 @@ import com.google.common.base.Function;
|
|||
import com.google.common.collect.ComputationException;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.mortennobel.imagescaling.ResampleOp;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
/**
|
||||
* This class stores ALL card images in a cache with soft values. this means
|
||||
|
|
@ -80,12 +81,13 @@ public class ImageCache {
|
|||
return loadImage(thumbnailFile);
|
||||
} else {
|
||||
BufferedImage image = loadImage(file);
|
||||
image = getWizardsCard(image);
|
||||
if (image == null) return null;
|
||||
//log.debug("creating thumbnail for " + key);
|
||||
return makeThumbnail(image, thumbnailPath);
|
||||
}
|
||||
} else {
|
||||
return loadImage(file);
|
||||
return getWizardsCard(loadImage(file));
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
|
|
@ -101,6 +103,18 @@ public class ImageCache {
|
|||
});
|
||||
}
|
||||
|
||||
public static BufferedImage getWizardsCard(BufferedImage image) {
|
||||
if (image.getWidth() == 265 && image.getHeight() == 370) {
|
||||
BufferedImage crop = new BufferedImage(256, 360, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D graphics2D = crop.createGraphics();
|
||||
graphics2D.drawImage(image, 0, 0, 255, 360, 5, 5, 261, 365, null);
|
||||
graphics2D.dispose();
|
||||
return crop;
|
||||
} else {
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
||||
public static BufferedImage getThumbnail(CardView card) {
|
||||
String key = getKey(card) + "#thumb";
|
||||
//log.debug("#key: " + key);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue