From cd90be13ec08dfc5468fed8c5bd4296b425e2965 Mon Sep 17 00:00:00 2001 From: Ali-RS Date: Sat, 6 Apr 2019 09:17:03 +0430 Subject: [PATCH] =?UTF-8?q?Revert=20"Modified=20JmeDesktopSystem.writeImag?= =?UTF-8?q?eFile()=20to=20export=20transparency=20for=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/jme3/system/JmeDesktopSystem.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java index 1ba8cb966..d02b5d21c 100644 --- a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java +++ b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java @@ -90,22 +90,20 @@ public class JmeDesktopSystem extends JmeSystemDelegate { @Override public void writeImageFile(OutputStream outStream, String format, ByteBuffer imageData, int width, int height) throws IOException { + BufferedImage awtImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); + Screenshots.convertScreenShot2(imageData.asIntBuffer(), awtImage); + ImageWriter writer = ImageIO.getImageWritersByFormatName(format).next(); ImageWriteParam writeParam = writer.getDefaultWriteParam(); - - BufferedImage awtImage; + if (format.equals("jpg")) { JPEGImageWriteParam jpegParam = (JPEGImageWriteParam) writeParam; jpegParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); jpegParam.setCompressionQuality(0.95f); - awtImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); - Screenshots.convertScreenShot2(imageData.asIntBuffer(), awtImage); - awtImage = verticalFlip(awtImage); - } else { - awtImage = new BufferedImage(width, height, BufferedImage.TYPE_4BYTE_ABGR); - Screenshots.convertScreenShot(imageData, awtImage); } + awtImage = verticalFlip(awtImage); + ImageOutputStream imgOut = new MemoryCacheImageOutputStream(outStream); writer.setOutput(imgOut); IIOImage outputImage = new IIOImage(awtImage, null, null);