From 90aedfa2a69387b5bcff6953563225a53cc7b086 Mon Sep 17 00:00:00 2001 From: "mikael.lantz" Date: Tue, 2 Feb 2021 16:36:19 +0100 Subject: [PATCH] fix: Change from INT_RGB to INT_ARGB when changing images to use 24-bit color depth --- .../java/se/lantz/gui/screenshot/EditScreenshotPanel.java | 4 ++-- src/main/java/se/lantz/util/FileManager.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/se/lantz/gui/screenshot/EditScreenshotPanel.java b/src/main/java/se/lantz/gui/screenshot/EditScreenshotPanel.java index e723a87..28d7933 100644 --- a/src/main/java/se/lantz/gui/screenshot/EditScreenshotPanel.java +++ b/src/main/java/se/lantz/gui/screenshot/EditScreenshotPanel.java @@ -206,7 +206,7 @@ public class EditScreenshotPanel extends JPanel private void updateLabelIcon() { - BufferedImage copyOfImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB); + BufferedImage copyOfImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = copyOfImage.createGraphics(); g.drawImage(image, 0, 0, null); g.setColor(Color.red); @@ -258,7 +258,7 @@ public class EditScreenshotPanel extends JPanel BufferedImage newImage = image .getSubimage(x, y, width, height); BufferedImage copyOfImage = - new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_RGB); + new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = copyOfImage.createGraphics(); g.drawImage(newImage, 0, 0, null); return newImage; diff --git a/src/main/java/se/lantz/util/FileManager.java b/src/main/java/se/lantz/util/FileManager.java index 3f4a808..eae67e4 100644 --- a/src/main/java/se/lantz/util/FileManager.java +++ b/src/main/java/se/lantz/util/FileManager.java @@ -91,7 +91,7 @@ public class FileManager { Image coverToSave = cover.getScaledInstance(122, 175, Image.SCALE_SMOOTH); BufferedImage copyOfImage = - new BufferedImage(coverToSave.getWidth(null), coverToSave.getHeight(null), BufferedImage.TYPE_INT_RGB); + new BufferedImage(coverToSave.getWidth(null), coverToSave.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = copyOfImage.createGraphics(); g.drawImage(coverToSave, 0, 0, null); g.dispose(); @@ -818,7 +818,7 @@ public class FileManager // Scale to right size. Image newImage = returnImage.getScaledInstance(320, 200, Image.SCALE_SMOOTH); BufferedImage copyOfImage = - new BufferedImage(newImage.getWidth(null), newImage.getHeight(null), BufferedImage.TYPE_INT_RGB); + new BufferedImage(newImage.getWidth(null), newImage.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = copyOfImage.createGraphics(); g.drawImage(newImage, 0, 0, null); return copyOfImage; @@ -832,7 +832,7 @@ public class FileManager BufferedImage newImage = originalImage .getSubimage((originalImage.getWidth() - 320) / 2, ((originalImage.getHeight() - 200) / 2) - 1, 320, 200); BufferedImage copyOfImage = - new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_RGB); + new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = copyOfImage.createGraphics(); g.drawImage(newImage, 0, 0, null); return newImage; @@ -844,7 +844,7 @@ public class FileManager BufferedImage newImage = originalImage .getSubimage((originalImage.getWidth() - 448) / 2, ((originalImage.getHeight() - 280) / 2) - 1, 448, 280); BufferedImage copyOfImage = - new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_RGB); + new BufferedImage(newImage.getWidth(), newImage.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = copyOfImage.createGraphics(); g.drawImage(newImage, 0, 0, null); return newImage;