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
This commit is contained in:
leriomaggio
2021-09-15 11:46:22 +01:00
parent 16612a8c7a
commit 62bd8efd1c

View File

@@ -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;