Mercurial > hg > Applications > TreeVNC
annotate src/main/java/com/glavsoft/rfb/encoding/decoder/ZRLEDecoder.java @ 560:bdd659ce8e64
fix null renderer
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 31 Jan 2020 11:41:13 +0900 |
parents | ff4c1972aa2e |
children | 5bbe53b47d0a |
rev | line source |
---|---|
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
1 // Copyright (C) 2010, 2011, 2012, 2013 GlavSoft LLC. |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 // All rights reserved. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is part of the TightVNC software. Please visit our Web site: |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 // http://www.tightvnc.com/ |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 // This program is free software; you can redistribute it and/or modify |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // it under the terms of the GNU General Public License as published by |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // the Free Software Foundation; either version 2 of the License, or |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 // (at your option) any later version. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 // This program is distributed in the hope that it will be useful, |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 // GNU General Public License for more details. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 // You should have received a copy of the GNU General Public License along |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 // with this program; if not, write to the Free Software Foundation, Inc., |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 //------------------------------------------------------------------------- |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 // |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 package com.glavsoft.rfb.encoding.decoder; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 import com.glavsoft.drawing.Renderer; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 import com.glavsoft.exceptions.TransportException; |
526 | 29 import com.glavsoft.rfb.encoding.EncodingType; |
545
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
30 import com.glavsoft.rfb.protocol.ReceiverTask; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 import com.glavsoft.transport.Reader; |
526 | 32 import jp.ac.u_ryukyu.treevnc.CheckDelay; |
498 | 33 import jp.ac.u_ryukyu.treevnc.TreeRFBProto; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 |
526 | 35 import java.io.UnsupportedEncodingException; |
36 import java.nio.ByteBuffer; | |
528 | 37 import java.util.LinkedList; |
526 | 38 import java.util.zip.Deflater; |
39 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 public class ZRLEDecoder extends ZlibDecoder { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
41 private static final int MAX_TILE_SIZE = 64; |
539 | 42 private int[] decodedBitmap; |
43 private int[] palette; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 |
539 | 45 class TileLoop { |
535 | 46 private final boolean blocking; |
538 | 47 private int deflate_size = 55507; |
528 | 48 private ByteBuffer c1; |
532 | 49 private int width; // phase2 length |
528 | 50 private FramebufferUpdateRectangle c1rect; |
51 private int prevLineOffset; | |
52 private int prevC1Offset; | |
541 | 53 private int prevC1LineOffset; |
528 | 54 private int prevoffset; |
55 private Deflater deflater; | |
56 | |
57 /** | |
58 * Multicast framebufferUpdate to children. | |
59 * read FrameBuffferUpdate. If it is ZLE, make it ZLEE which is self contained compressed packet. | |
60 * put the packet to the multicastqueue. Then normal rendering engine read the same stream using is.reset(). | |
539 | 61 * <p> |
528 | 62 * Haeder |
539 | 63 * messageID ( FrameBuffer Update |
64 * 1 byte padding | |
65 * 2 byte numberofrectangle | |
66 * 2 - U16 - x-position | |
67 * 2 - U16 - y-position | |
68 * 2 - U16 - width | |
69 * 2 - U16 - height | |
70 * 4 - S32 - encoding-type | |
71 * 4 byte datalengths | |
72 * datalengths databyte | |
528 | 73 * |
74 * @throws TransportException | |
75 * @throws UnsupportedEncodingException | |
76 */ | |
77 | |
533 | 78 public TileLoop(int offset) { |
539 | 79 prevoffset = prevLineOffset = offset; |
80 prevC1Offset = 0; | |
81 if (offset < deflate_size + spanGap) { | |
535 | 82 // packet size fit in broadcast send it all at once |
83 blocking = false; | |
84 } else | |
85 blocking = true; | |
533 | 86 } |
528 | 87 |
535 | 88 private void zrleeBlocking(TreeRFBProto rfb, ByteBuffer header, FramebufferUpdateRectangle rect, byte bytes[]) { |
528 | 89 // dump32(inputs); |
90 deflater = rfb.deflater; | |
541 | 91 c1rect = new FramebufferUpdateRectangle(rect.x, rect.y, 0, 0); |
532 | 92 newMulticastPacket(rfb, rect); |
93 c1.put(header.get(0)); | |
535 | 94 if (!blocking) { |
539 | 95 deflater.setInput(bytes, 0, prevoffset); |
535 | 96 deflater.deflate(c1); |
97 flushMuticast(rfb); | |
98 } | |
532 | 99 return; |
100 } | |
101 | |
102 private void newMulticastPacket(TreeRFBProto rfb, FramebufferUpdateRectangle rect) { | |
539 | 103 c1 = rfb.multicastqueue.allocate(deflate_size + 20); |
104 c1.limit(c1.limit() - 20); | |
528 | 105 if (rfb.addSerialNum) |
106 c1.putLong(rfb.counter++); | |
107 if (rfb.checkDelay) | |
108 CheckDelay.checkDelay(c1, rect.x, rect.y, rect.width, rect.height, System.currentTimeMillis(), EncodingType.CHECK_DELAY); | |
541 | 109 c1.put((byte) 0); |
532 | 110 c1.put((byte) 0); |
111 c1.putShort((short) 0); | |
550
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
112 c1.position(c1.position() + 12); |
532 | 113 c1.putInt(0); // should be data length |
539 | 114 prevC1Offset = c1.position(); |
541 | 115 prevC1LineOffset = prevC1Offset; |
532 | 116 width = 0; |
541 | 117 c1rect.width = c1rect.height = 0; |
528 | 118 } |
531
13d3c4341d14
remove .idea modules fix for loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
529
diff
changeset
|
119 |
528 | 120 int spanGap = 128; |
121 /** | |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
122 * Series of tiles compose at most three rectangles. SYNC_FLUSH is necessary on |
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
123 * rectangle boundaries. |
539 | 124 * <p> |
545
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
125 * +----+ |
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
126 * | | phase 0 |
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
127 * +---------------+ |
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
128 * | | phase 1 |
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
129 * +----+----------+ |
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
130 * | | phase 2 |
1ba61b57be39
add test routine in -p ( running as root mode )
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
543
diff
changeset
|
131 * +----+ |
539 | 132 * <p> |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
133 * Broadcast packet have to less than 64kbytes |
539 | 134 * A tile 64x64x3 11288byte, a packet can contain 5 raw tiles, when these are |
135 * compressed 10 to 100 tiles can be stored. It is impossible to predict the | |
136 * compression rate. To check the compressed capacity, Deflate.needsInputs() can | |
137 * be used. If needsInputs() is false on SYNC_FLUSH, smaller input is necessary. | |
138 * <p> | |
139 * We'll try 512 tiles before SYNC_FLUSH in a phase, if it fails try flush former 256 tiles. | |
140 * If it will failed again, flush the previous line and do flush 512 tiles in new Packet. | |
141 * If it failed again try former 256 tiles flushed, if this failes again dicard the former half. | |
142 * The last case cannot happen but former 256 tiles have to be flushed, because the next 256 lines | |
143 * may failed again and restart the from this point. | |
144 * The next packet start with later 256 tiles filled and unflushed. | |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
145 * |
528 | 146 * @param rfb |
147 * @param last | |
148 * @param rect | |
149 * @param bytes | |
150 * @param offset | |
151 * @param tileW | |
152 * @param tileH | |
153 */ | |
539 | 154 |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
155 int MAX_ZTILE = 512; |
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
156 |
531
13d3c4341d14
remove .idea modules fix for loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
529
diff
changeset
|
157 public void multicastPut(TreeRFBProto rfb, boolean last, FramebufferUpdateRectangle rect, byte[] bytes, int offset, int tileW, int tileH) { |
535 | 158 if (!blocking) return; |
528 | 159 int span = offset - prevoffset; |
539 | 160 deflater.setInput(bytes, prevoffset, span); |
528 | 161 prevoffset = offset; |
539 | 162 width += tileW; |
532 | 163 if (c1rect.x > rect.x) { // phase 0 |
539 | 164 if (c1rect.x + c1rect.width < rect.x + rect.width) { |
165 compressAndCheckFlush(rfb, rect, bytes, offset, false, last); | |
532 | 166 } else { |
539 | 167 c1rect.width = rect.x + rect.width - c1rect.x; |
541 | 168 prevC1LineOffset = c1.position(); |
539 | 169 compressAndCheckFlush(rfb, rect, bytes, offset, true, last); |
528 | 170 } |
538 | 171 } else { // phase 1 |
532 | 172 if (width >= rect.width) { |
173 c1rect.width = rect.width; | |
174 width = 0; | |
531
13d3c4341d14
remove .idea modules fix for loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
529
diff
changeset
|
175 prevLineOffset = offset; |
541 | 176 prevC1LineOffset = c1.position(); |
539 | 177 compressAndCheckFlush(rfb, rect, bytes, offset, true, last); |
533 | 178 } else { |
538 | 179 compressAndCheckFlush(rfb, rect, bytes, offset, false, last); |
541 | 180 |
181 | |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
182 } |
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
183 } |
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
184 } |
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
185 |
541 | 186 private boolean compressAndCheckFlush(TreeRFBProto rfb, FramebufferUpdateRectangle rect, byte[] bytes, int offset, boolean flush, boolean last) { |
538 | 187 deflater.deflate(c1, Deflater.NO_FLUSH); |
188 int headerLength = 20; | |
189 if (!deflater.needsInput()) { | |
190 deflater.finish(); | |
539 | 191 if (offset != prevLineOffset) { |
192 // fix phase1 rectangle header | |
550
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
193 //c1.putShort(prevC1Offset - 16, (short) c1rect.x); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
194 //c1.putShort(prevC1Offset - 14, (short) c1rect.y); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
195 //c1.putShort(prevC1Offset - 12, (short) c1rect.width); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
196 //c1.putShort(prevC1Offset - 10, (short) c1rect.height); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
197 //c1.putInt(prevC1Offset - 8, EncodingType.ZRLEE.getId()); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
198 //c1.putInt(prevC1Offset - 4, c1.position() - prevC1LineOffset - 12); // data length |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
199 //c1.putShort(2, (short) (c1.getShort(2) + 1)); // increment rectangle count |
539 | 200 |
541 | 201 |
550
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
202 //if (c1rect.x == rect.x) { // phase0 needs no phase1 |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
203 // // make header space for phase2 |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
204 // c1.limit(c1.limit() + headerLength); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
205 // int pos = c1.position() - 1; |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
206 // // to make rectangle header shift last bytes |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
207 // for (int i = 0; i < pos - prevC1LineOffset; i++) { |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
208 // c1.array()[pos + headerLength - i] = c1.array()[pos - i]; |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
209 // } |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
210 // prevC1Offset = prevC1LineOffset; |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
211 //} |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
212 } |
539 | 213 flushRectangle(rect); |
538 | 214 flushMuticast(rfb); |
215 newMulticastPacket(rfb, rect); | |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
216 deflater.deflate(c1, Deflater.NO_FLUSH); |
541 | 217 return true; |
539 | 218 } else if (last) { |
219 flushRectangle(rect); | |
220 flushMuticast(rfb); | |
541 | 221 return true; |
528 | 222 } |
541 | 223 return false; |
528 | 224 } |
225 | |
226 /** | |
227 * fix rectangle header | |
228 * create next rectangle header | |
229 * update position paramater | |
230 * send muticast pacate if nessesally | |
231 */ | |
532 | 232 private void flushRectangle(FramebufferUpdateRectangle rect) { |
550
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
233 c1.putShort(prevC1Offset - 16, (short) c1rect.x); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
234 c1.putShort(prevC1Offset - 14, (short) c1rect.y); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
235 c1.putShort(prevC1Offset - 12, (short) c1rect.width); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
236 c1.putShort(prevC1Offset - 10, (short) c1rect.height); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
237 c1.putInt(prevC1Offset - 8, EncodingType.ZRLEE.getId()); |
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
238 c1.putInt(prevC1Offset - 4, c1.position() - prevC1Offset - 12); // data length |
539 | 239 c1.putShort(2, (short) (c1.getShort(2) + 1)); // increment rectangle count |
240 prevC1Offset = c1.position(); | |
541 | 241 |
242 nextPhase(rect); | |
534
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
243 } |
a3d0ba67e8cf
try 512 tiles / 256 tiles flush
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
533
diff
changeset
|
244 |
541 | 245 private void nextPhase(FramebufferUpdateRectangle rect) { |
539 | 246 if (c1rect.x + c1rect.width < rect.x + rect.width) { |
532 | 247 c1rect.x = c1rect.width; // next rectangle is phase 1 |
248 } else { | |
249 c1rect.x = rect.x; | |
250 c1rect.y += c1rect.height; | |
251 } | |
252 width = 0; | |
528 | 253 } |
254 | |
531
13d3c4341d14
remove .idea modules fix for loop
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
529
diff
changeset
|
255 private void flushMuticast(TreeRFBProto rfb) { |
528 | 256 c1.flip(); |
257 //System.out.println("multicastPut: " + c1rect + " length: " + (c1.remaining()-c1headerPos-header.limit())); | |
529 | 258 deflater.reset(); |
259 | |
260 LinkedList<ByteBuffer> bufs = new LinkedList<ByteBuffer>(); | |
261 bufs.add(c1); | |
552 | 262 rfb.getContext().checkFrameBufferRectanble(c1); |
529 | 263 if (rfb.isTreeManager() && rfb.connectionPresenter.isUseMulticast()) { |
264 for (ByteBuffer buf : bufs) | |
265 rfb.getViewer().getRfbBroadcastListener().multicastUpdateRectangle(buf); | |
266 } else { | |
560 | 267 rfb.multicastqueue.put(bufs); |
529 | 268 } |
528 | 269 } |
270 } | |
526 | 271 |
272 @Override | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
273 public void decode(Reader reader, Renderer renderer, |
539 | 274 FramebufferUpdateRectangle rect) throws TransportException { |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
275 int zippedLength = (int) reader.readUInt32(); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276 if (0 == zippedLength) return; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 int length = rect.width * rect.height * renderer.getBytesPerPixel(); |
3 | 278 byte[] bytes = unzip(reader, zippedLength, length, rect.getEncodingType()); |
526 | 279 decode1(renderer, null, rect, bytes, zippedLength, null); |
539 | 280 } |
533 | 281 |
282 | |
283 public void multicastDecode(Reader reader, Renderer renderer, | |
539 | 284 FramebufferUpdateRectangle rect, TreeRFBProto rfb) throws TransportException { |
285 ByteBuffer header = ByteBuffer.allocate(16); | |
286 reader.read(header.array()); | |
533 | 287 int zippedLength = (int) reader.readUInt32(); |
288 if (0 == zippedLength) return; | |
289 int length = rect.width * rect.height * renderer.getBytesPerPixel(); | |
290 byte[] bytes = unzip(reader, zippedLength, length, rect.getEncodingType()); | |
291 decode1(renderer, header, rect, bytes, zippedLength, rfb); | |
292 } | |
293 | |
526 | 294 public void decode1(Renderer renderer, ByteBuffer header, FramebufferUpdateRectangle rect, byte[] bytes, int zippedLength, TreeRFBProto rfbProto) throws TransportException { |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 int offset = zippedLength; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296 int maxX = rect.x + rect.width; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 int maxY = rect.y + rect.height; |
528 | 298 |
533 | 299 TileLoop tileloop = new TileLoop(zippedLength); |
550
9c0cbe119155
fix make rectangle packet in client
e165729 <e165729@ie.u-ryukyu.ac.jp>
parents:
545
diff
changeset
|
300 //System.out.println("decode1: "+rect.toString()); |
539 | 301 if (null == palette) { |
302 palette = new int[128]; | |
303 } | |
304 if (null == decodedBitmap) { | |
305 decodedBitmap = new int[MAX_TILE_SIZE * MAX_TILE_SIZE]; | |
306 } | |
526 | 307 |
539 | 308 if (rfbProto.multicastBlocking) { |
309 tileloop.zrleeBlocking(rfbProto, header, rect, bytes); | |
526 | 310 } |
539 | 311 try { |
312 for (int tileY = rect.y; tileY < maxY; tileY += MAX_TILE_SIZE) { | |
313 int tileHeight = Math.min(maxY - tileY, MAX_TILE_SIZE); | |
541 | 314 tileloop.c1rect.height += tileHeight; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 |
539 | 316 for (int tileX = rect.x; tileX < maxX; tileX += MAX_TILE_SIZE) { |
317 int tileWidth = Math.min(maxX - tileX, MAX_TILE_SIZE); | |
541 | 318 tileloop.c1rect.width += tileWidth; |
539 | 319 int subencoding = bytes[offset++] & 0x0ff; |
320 if (subencoding != 0) | |
321 System.out.println("----------------" + subencoding); | |
322 // 128 -plain RLE, 130-255 - Palette RLE | |
323 boolean isRle = (subencoding & 128) != 0; | |
324 // 2 to 16 for raw packed palette data, 130 to 255 for Palette RLE (subencoding - 128) | |
325 int paletteSize = subencoding & 127; | |
326 offset += readPalette(bytes, offset, renderer, paletteSize); | |
327 if (1 == subencoding) { // A solid tile consisting of a single colour | |
328 renderer.fillRect(palette[0], tileX, tileY, tileWidth, tileHeight); | |
329 } else if (isRle) { | |
330 if (0 == paletteSize) { // subencoding == 128 (or paletteSize == 0) - Plain RLE | |
331 offset += decodePlainRle(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight); | |
332 } else { | |
333 offset += decodePaletteRle(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight); | |
334 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
335 } else { |
539 | 336 if (0 == paletteSize) { // subencoding == 0 (or paletteSize == 0) - raw CPIXEL data |
337 offset += decodeRaw(bytes, offset, renderer, tileX, tileY, tileWidth, tileHeight); | |
63 | 338 // System.out.println("offset:"+offset); |
539 | 339 } else { |
340 offset += decodePacked(bytes, offset, renderer, paletteSize, tileX, tileY, tileWidth, tileHeight); | |
341 } | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
342 } |
539 | 343 if (rfbProto != null && rfbProto.multicastBlocking) |
344 tileloop.multicastPut(rfbProto, false, rect, bytes, offset, tileWidth, tileHeight); | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
345 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
346 } |
539 | 347 if (rfbProto != null && rfbProto.multicastBlocking) |
348 tileloop.multicastPut(rfbProto, true, rect, bytes, offset, 0, 0); | |
349 } catch (Exception e) { | |
560 | 350 e.printStackTrace(); |
539 | 351 if (rfbProto != null && rfbProto.multicastBlocking) |
352 tileloop.multicastPut(rfbProto, true, rect, bytes, offset, 0, 0); | |
353 throw e; | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
355 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
356 |
539 | 357 |
358 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
359 private int decodePlainRle(byte[] bytes, int offset, Renderer renderer, |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
360 int tileX, int tileY, int tileWidth, int tileHeight) { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
361 int bytesPerCPixel = renderer.getBytesPerCPixel(); |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
362 int decodedOffset = 0; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
363 int decodedEnd = tileWidth * tileHeight; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
364 int index = offset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
365 while (decodedOffset < decodedEnd) { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
366 int color = renderer.getCompactPixelColor(bytes, index); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
367 index += bytesPerCPixel; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
368 int rlength = 1; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
369 do { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
370 rlength += bytes[index] & 0x0ff; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
371 } while ((bytes[index++] & 0x0ff) == 255); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
372 assert rlength <= decodedEnd - decodedOffset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
373 renderer.fillColorBitmapWithColor(decodedBitmap, decodedOffset, rlength, color); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
374 decodedOffset += rlength; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
375 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
376 renderer.drawColoredBitmap(decodedBitmap, tileX, tileY, tileWidth, tileHeight); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
377 return index - offset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
378 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
379 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
380 private int decodePaletteRle(byte[] bytes, int offset, Renderer renderer, |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
381 int tileX, int tileY, int tileWidth, int tileHeight) { |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
382 int decodedOffset = 0; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
383 int decodedEnd = tileWidth * tileHeight; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
384 int index = offset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
385 while (decodedOffset < decodedEnd) { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
386 int colorIndex = bytes[index++]; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
387 int color = palette[colorIndex & 127]; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
388 int rlength = 1; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
389 if ((colorIndex & 128) != 0) { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
390 do { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
391 rlength += bytes[index] & 0x0ff; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
392 } while (bytes[index++] == (byte) 255); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
393 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
394 assert rlength <= decodedEnd - decodedOffset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
395 renderer.fillColorBitmapWithColor(decodedBitmap, decodedOffset, rlength, color); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
396 decodedOffset += rlength; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
397 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
398 renderer.drawColoredBitmap(decodedBitmap, tileX, tileY, tileWidth, tileHeight); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
399 return index - offset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
400 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
401 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
402 private int decodePacked(byte[] bytes, int offset, Renderer renderer, |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
403 int paletteSize, int tileX, int tileY, int tileWidth, int tileHeight) { |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
404 int bitsPerPalletedPixel = paletteSize > 16 ? 8 : paletteSize > 4 ? 4 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
405 : paletteSize > 2 ? 2 : 1; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
406 int packedOffset = offset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
407 int decodedOffset = 0; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
408 for (int i = 0; i < tileHeight; ++i) { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
409 int decodedRowEnd = decodedOffset + tileWidth; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
410 int byteProcessed = 0; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
411 int bitsRemain = 0; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
412 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
413 while (decodedOffset < decodedRowEnd) { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
414 if (bitsRemain == 0) { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
415 byteProcessed = bytes[packedOffset++]; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
416 bitsRemain = 8; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
417 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
418 bitsRemain -= bitsPerPalletedPixel; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
419 int index = byteProcessed >> bitsRemain & (1 << bitsPerPalletedPixel) - 1 & 127; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
420 int color = palette[index]; |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
421 renderer.fillColorBitmapWithColor(decodedBitmap, decodedOffset, 1, color); |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
422 ++decodedOffset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
423 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
424 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
425 renderer.drawColoredBitmap(decodedBitmap, tileX, tileY, tileWidth, tileHeight); |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
426 return packedOffset - offset; |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
427 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
428 |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
429 private int decodeRaw(byte[] bytes, int offset, Renderer renderer, |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
430 int tileX, int tileY, int tileWidth, int tileHeight) throws TransportException { |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
431 return renderer.drawCompactBytes(bytes, offset, tileX, tileY, tileWidth, tileHeight); |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
432 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
433 |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
434 private int readPalette(byte[] bytes, int offset, Renderer renderer, int paletteSize) { |
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
435 final int bytesPerCPixel = renderer.getBytesPerCPixel(); |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
436 for (int i=0; i<paletteSize; ++i) { |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
437 palette[i] = renderer.getCompactPixelColor(bytes, offset + i* bytesPerCPixel); |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
438 } |
57
17b702648079
version2.7.2 original version.
Taninari YU <you@cr.ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
439 return paletteSize * bytesPerCPixel; |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
440 } |
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
441 |
526 | 442 |
443 | |
0
4689cc86d6cb
create TreeViewer2 Repository
Yu Taninari <you@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
444 } |