blob: 94a82d3839422d4d33da72f741c8335ec9082bcc [file] [log] [blame]
enikeyf7160bd2008-12-19 07:54:40 +00001package com.tightvnc.decoder;
2
3import com.tightvnc.decoder.common.Repaintable;
4import com.tightvnc.vncviewer.RfbInputStream;
5import java.awt.Graphics;
6import java.awt.Color;
7import java.awt.Image;
8import java.awt.Rectangle;
9import java.awt.Toolkit;
10import java.awt.image.ImageObserver;
11import java.util.zip.Inflater;
12
13//
14// Class that used for decoding Tight encoded data.
15//
16
17public class TightDecoder extends RawDecoder {
18
19 //
20 // Tight decoder constants
21 //
22
23 final static int TightExplicitFilter = 0x04;
24 final static int TightFill = 0x08;
25 final static int TightJpeg = 0x09;
26 final static int TightMaxSubencoding = 0x09;
27 final static int TightFilterCopy = 0x00;
28 final static int TightFilterPalette = 0x01;
29 final static int TightFilterGradient = 0x02;
30 final static int TightMinToCompress = 12;
31
32 // Tight encoder's data.
33 final static int tightZlibBufferSize = 512;
34
35 public TightDecoder(Graphics g, RfbInputStream is) {
36 super(g, is);
37 tightInflaters = new Inflater[4];
38 }
39
40 public TightDecoder(Graphics g, RfbInputStream is, int frameBufferW,
41 int frameBufferH) {
42 super(g, is, frameBufferW, frameBufferH);
43 tightInflaters = new Inflater[4];
44 }
45
46 //
47 // Set and get methods for private TightDecoder
48 //
49
50 public void setRepainableControl(Repaintable r) {
51 repainatableControl = r;
52 }
53
54 //
55 // JPEG processing statistic methods
56 //
57
58 public int getNumJPEGRects() {
59 return statNumRectsTightJPEG;
60 }
61
62 public void setNumJPEGRects(int v) {
63 statNumRectsTightJPEG = v;
64 }
65
66 //
67 // Private members
68 //
69
70 private Inflater[] tightInflaters;
71 // Since JPEG images are loaded asynchronously, we have to remember
72 // their position in the framebuffer. Also, this jpegRect object is
73 // used for synchronization between the rfbThread and a JVM's thread
74 // which decodes and loads JPEG images.
75 private Rectangle jpegRect;
76 private Repaintable repainatableControl = null;
77 // Jpeg decoding statistics
78 private int statNumRectsTightJPEG = 0;
79}