(Rect r, Object buffer,
int buflen, ServerParams server,
ModifiablePixelBuffer pb)
| 181 | } |
| 182 | |
| 183 | public void decodeRect(Rect r, Object buffer, |
| 184 | int buflen, ServerParams server, |
| 185 | ModifiablePixelBuffer pb) |
| 186 | { |
| 187 | ByteBuffer bufptr; |
| 188 | PixelFormat pf = server.pf(); |
| 189 | |
| 190 | int comp_ctl; |
| 191 | |
| 192 | bufptr = ByteBuffer.wrap((byte[])buffer); |
| 193 | |
| 194 | assert(buflen >= 1); |
| 195 | |
| 196 | comp_ctl = bufptr.get() & 0xff; |
| 197 | buflen -= 1; |
| 198 | |
| 199 | // Reset zlib streams if we are told by the server to do so. |
| 200 | for (int i = 0; i < 4; i++) { |
| 201 | if ((comp_ctl & 1) != 0) { |
| 202 | zis[i].reset(); |
| 203 | } |
| 204 | comp_ctl >>= 1; |
| 205 | } |
| 206 | |
| 207 | // "Fill" compression type. |
| 208 | if (comp_ctl == tightFill) { |
| 209 | if (pf.is888()) { |
| 210 | ByteBuffer pix = ByteBuffer.allocate(4); |
| 211 | |
| 212 | assert(buflen >= 3); |
| 213 | |
| 214 | pf.bufferFromRGB(pix.duplicate(), bufptr, 1); |
| 215 | pb.fillRect(pf, r, pix.array()); |
| 216 | } else { |
| 217 | assert(buflen >= pf.bpp/8); |
| 218 | byte[] pix = new byte[pf.bpp/8]; |
| 219 | bufptr.get(pix); |
| 220 | pb.fillRect(pf, r, pix); |
| 221 | } |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | // "JPEG" compression type. |
| 226 | if (comp_ctl == tightJpeg) { |
| 227 | int len; |
| 228 | |
| 229 | WritableRaster buf; |
| 230 | |
| 231 | JpegDecompressor jd = new JpegDecompressor(); |
| 232 | |
| 233 | assert(buflen >= 4); |
| 234 | |
| 235 | len = bufptr.getInt(); |
| 236 | buflen -= 4; |
| 237 | |
| 238 | // We always use direct decoding with JPEG images |
| 239 | jd.decompress(bufptr, len, pb, r, pb.getPF()); |
| 240 | pb.commitBufferRW(r); |
nothing calls this directly
no test coverage detected