aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian P. Hinz <bphinz@users.sf.net>2017-04-04 21:10:00 -0400
committerBrian P. Hinz <bphinz@users.sf.net>2017-04-04 21:17:03 -0400
commit83722048ddbe3eafe41bdccca4d706e98b25103b (patch)
tree0f6aa3b0bb8f21fd842ed353e6e83e1814fa3e86
parentefd93fd97bedd5fba60780f016117383e85d8b59 (diff)
downloadtigervnc-83722048ddbe3eafe41bdccca4d706e98b25103b.tar.gz
tigervnc-83722048ddbe3eafe41bdccca4d706e98b25103b.zip
Partial fix for java viewer performance regression
-rw-r--r--java/com/tigervnc/rfb/JpegDecompressor.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/java/com/tigervnc/rfb/JpegDecompressor.java b/java/com/tigervnc/rfb/JpegDecompressor.java
index 9137847c..c263736b 100644
--- a/java/com/tigervnc/rfb/JpegDecompressor.java
+++ b/java/com/tigervnc/rfb/JpegDecompressor.java
@@ -17,6 +17,7 @@
*/
package com.tigervnc.rfb;
+import java.awt.*;
import java.awt.image.*;
import java.io.*;
import java.nio.ByteBuffer;
@@ -35,17 +36,16 @@ public class JpegDecompressor {
jpegBuf.get(src);
try {
- BufferedImage image =
+ ImageIO.setUseCache(false);
+ BufferedImage jpeg =
ImageIO.read(new MemoryCacheImageInputStream(new ByteArrayInputStream(src)));
ColorModel cm = pf.getColorModel();
- if (cm.isCompatibleRaster(image.getRaster()) &&
- cm.isCompatibleSampleModel(image.getRaster().getSampleModel())) {
- buf.setDataElements(0, 0, image.getRaster());
- } else {
- ColorConvertOp converter = pf.getColorConvertOp(cm.getColorSpace());
- converter.filter(image.getRaster(), buf);
- }
+ BufferedImage image = new BufferedImage(cm, buf, true, null);
+ Graphics2D g2 = image.createGraphics();
+ g2.drawImage(jpeg, 0, 0, null);
+ g2.dispose();
image.flush();
+ jpeg.flush();
} catch (IOException e) {
throw new Exception(e.getMessage());
}