From 62bd8efd1c1e738ba5aeddb3a70b850bcab6dccd Mon Sep 17 00:00:00 2001 From: leriomaggio Date: Wed, 15 Sep 2021 11:46:22 +0100 Subject: [PATCH] Patch to CardPicturePanel to work on cropped Card Images BufferedImage (deep) copy procedure applied in CardPicturePanel may not always work when the input image has been originally cropped. The issue is caused by `image.copyData(null)` which may sometimes work on the original (uncropped) underlying raster. This patch fixes this issue! Source: https://stackoverflow.com/a/26894825/2969461 --- forge-gui-desktop/src/main/java/forge/gui/CardPicturePanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge-gui-desktop/src/main/java/forge/gui/CardPicturePanel.java b/forge-gui-desktop/src/main/java/forge/gui/CardPicturePanel.java index 92755cf7f29..b95bff564aa 100644 --- a/forge-gui-desktop/src/main/java/forge/gui/CardPicturePanel.java +++ b/forge-gui-desktop/src/main/java/forge/gui/CardPicturePanel.java @@ -84,7 +84,7 @@ public final class CardPicturePanel extends JPanel implements ImageFetcher.Callb if (displayed instanceof PaperCard) { ColorModel cm = image.getColorModel(); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); - WritableRaster raster = image.copyData(null); + WritableRaster raster = image.copyData(image.getRaster().createCompatibleWritableRaster()); final BufferedImage displayedimage = new BufferedImage(cm, raster, isAlphaPremultiplied, null) .getSubimage(0, 0, image.getWidth(), image.getHeight()); this.currentImage = displayedimage;