summaryrefslogtreecommitdiff
path: root/htroot/api
diff options
context:
space:
mode:
authorluccioman <luccioman@users.noreply.github.com>2017-10-19 09:27:52 +0200
committerluccioman <luccioman@users.noreply.github.com>2017-10-19 09:27:52 +0200
commit1de86cf1bf35698359b3c1a7e32a32cdc5ba32b8 (patch)
treef52a58dbab5b61c889d500f8391be7d732b5cabd /htroot/api
parentc1c4174816e82cd665f161a926368e9a4cf727bb (diff)
Fixed JPEG snapshot resizing when running on OpenJDK.
Resizing JPEG snapshot images through /api/snapshot.jpg failed when running on OpenJDK, but rendered successfully with a Oracle JDK. Details in mantis 772 ( http://mantis.tokeek.de/view.php?id=772 ). Removing any alpha component (useless in snapshot images) from the rendered resized image solves the issue.
Diffstat (limited to 'htroot/api')
-rw-r--r--htroot/api/snapshot.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/htroot/api/snapshot.java b/htroot/api/snapshot.java
index db60af1b7..c79c1eb97 100644
--- a/htroot/api/snapshot.java
+++ b/htroot/api/snapshot.java
@@ -21,6 +21,7 @@
import java.awt.Container;
import java.awt.Image;
import java.awt.MediaTracker;
+import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@@ -312,7 +313,14 @@ public class snapshot {
final MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(scaled, 0);
try {mediaTracker.waitForID(0);} catch (final InterruptedException e) {}
- return new EncodedImage(scaled, ext, true);
+
+ /*
+ * Ensure there is no alpha component on the ouput image, as it is pointless
+ * here and it is not well supported by the JPEGImageWriter from OpenJDK
+ */
+ BufferedImage scaledBufferedImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ scaledBufferedImg.createGraphics().drawImage(scaled, 0, 0, width, height, null);
+ return new EncodedImage(scaledBufferedImg, ext, true);
} catch (IOException e) {
ConcurrentLog.logException(e);
return null;