Color pixel;  pixel = new Color(0xFF000000 | rfb.is.readInt());
rfb.is.readFully(buf); Color pixel = new Color((buf[2] & 0xFF) << 16 | (buf[1] & 0xFF) << 8 | (buf[0] & 0xFF));
  public void processNormalProtocol() throws IOException {    zlibInflater = new Inflater();    tightInflaters = new Inflater[4];    // Main dispatch loop.    while (true) {      while (player.getMode() != player.MODE_PLAYBACK) {	synchronized(this) {	  try {	    wait();	  } catch (InterruptedException e) {	  }	}	if (player.getMode() == player.MODE_STOPPED) {	  throw new EOFException("Playback stopped");	}	if (player.getMode() == player.MODE_PLAYBACK) {	  player.fbsStream.resumeReading();	}      }      int msgType = rfb.readServerMessageType();      switch (msgType) {      case RfbProto.FramebufferUpdate:	rfb.readFramebufferUpdate();	for (int i = 0; i < rfb.updateNRects; i++) {	  rfb.readFramebufferUpdateRectHdr();	  if (rfb.updateRectEncoding == rfb.EncodingLastRect)	    break;	  if (rfb.updateRectEncoding == rfb.EncodingNewFBSize) {	    rfb.setFramebufferSize(rfb.updateRectW, rfb.updateRectH);	    updateFramebufferSize();	    break;	  }	  if (rfb.updateRectEncoding == rfb.EncodingXCursor ||	      rfb.updateRectEncoding == rfb.EncodingRichCursor) {	    throw new IOException("Sorry, no support for" +				  " cursor shape updates yet");	  }	  switch (rfb.updateRectEncoding) {	  case RfbProto.EncodingRaw:	  {	    handleRawRect(rfb.updateRectX, rfb.updateRectY,			  rfb.updateRectW, rfb.updateRectH);	    break;	  }	  case RfbProto.EncodingCopyRect:	  {	    rfb.readCopyRect();	    int sx = rfb.copyRectSrcX, sy = rfb.copyRectSrcY;	    int rx = rfb.updateRectX, ry = rfb.updateRectY;	    int rw = rfb.updateRectW, rh = rfb.updateRectH;	    memGraphics.copyArea(sx, sy, rw, rh, rx - sx, ry - sy);	    scheduleRepaint(rx, ry, rw, rh);	    break;	  }	  case RfbProto.EncodingRRE:	  {	    int rx = rfb.updateRectX, ry = rfb.updateRectY;	    int rw = rfb.updateRectW, rh = rfb.updateRectH;	    int nSubrects = rfb.is.readInt();	    int x, y, w, h;	    Color pixel;	    pixel = new Color(0xFF000000 | rfb.is.readInt());	    memGraphics.setColor(pixel);	    memGraphics.fillRect(rx, ry, rw, rh);	    for (int j = 0; j < nSubrects; j++) {	      pixel = new Color(0xFF000000 | rfb.is.readInt());	      x = rx + rfb.is.readUnsignedShort();	      y = ry + rfb.is.readUnsignedShort();	      w = rfb.is.readUnsignedShort();	      h = rfb.is.readUnsignedShort();	      memGraphics.setColor(pixel);	      memGraphics.fillRect(x, y, w, h);	    }	    scheduleRepaint(rx, ry, rw, rh);	    break;	  }	  case RfbProto.EncodingCoRRE:	  {	    int rx = rfb.updateRectX, ry = rfb.updateRectY;	    int rw = rfb.updateRectW, rh = rfb.updateRectH;	    int nSubrects = rfb.is.readInt();	    int x, y, w, h;	    Color pixel;	    pixel = new Color(0xFF000000 | rfb.is.readInt());	    memGraphics.setColor(pixel);	    memGraphics.fillRect(rx, ry, rw, rh);	    for (int j = 0; j < nSubrects; j++) {	      pixel = new Color(0xFF000000 | rfb.is.readInt());	      x = rx + rfb.is.readUnsignedByte();	      y = ry + rfb.is.readUnsignedByte();	      w = rfb.is.readUnsignedByte();	      h = rfb.is.readUnsignedByte();	      memGraphics.setColor(pixel);	      memGraphics.fillRect(x, y, w, h);	    }	    scheduleRepaint(rx, ry, rw, rh);	    break;	  }	  case RfbProto.EncodingHextile:	  {	    byte[] buf = new byte[256 * 4];	    int rx = rfb.updateRectX, ry = rfb.updateRectY;	    int rw = rfb.updateRectW, rh = rfb.updateRectH;	    Color bg = new Color(0), fg = new Color(0);	    for (int ty = ry; ty < ry + rh; ty += 16) {	      int th = 16;	      if (ry + rh - ty < 16)		th = ry + rh - ty;	      for (int tx = rx; tx < rx + rw; tx += 16) {		int tw = 16;		if (rx + rw - tx < 16)		  tw = rx + rw - tx;		int subencoding = rfb.is.readUnsignedByte();		// Is it a raw-encoded sub-rectangle?		if ((subencoding & rfb.HextileRaw) != 0) {		  int count, offset;		  for (int j = ty; j < ty + th; j++) {		    rfb.is.readFully(buf, 0, tw * 4);		    offset = j * rfb.framebufferWidth + tx;		    for (count = 0; count < tw; count++) {		      pixels24[offset + count] =			(buf[count * 4 + 2] & 0xFF) << 16 |			(buf[count * 4 + 1] & 0xFF) << 8 |			(buf[count * 4] & 0xFF);		    }		  }		  handleUpdatedPixels(tx, ty, tw, th);		  continue;		}		// Read and draw the background if specified.		if ((subencoding & rfb.HextileBackgroundSpecified) != 0) {		  rfb.is.readFully(buf, 0, 4);		  bg = new Color((buf[2] & 0xFF) << 16 |				 (buf[1] & 0xFF) << 8 |				 (buf[0] & 0xFF));		}		memGraphics.setColor(bg);		memGraphics.fillRect(tx, ty, tw, th);		// Read the foreground color if specified.		if ((subencoding & rfb.HextileForegroundSpecified) != 0) {		  rfb.is.readFully(buf, 0, 4);		  fg = new Color((buf[2] & 0xFF) << 16 |				 (buf[1] & 0xFF) << 8 |				 (buf[0] & 0xFF));		}		// Done with this tile if there is no sub-rectangles.		if ((subencoding & rfb.HextileAnySubrects) == 0)		  continue;		int nSubrects = rfb.is.readUnsignedByte();		int b1, b2, sx, sy, sw, sh;		if ((subencoding & rfb.HextileSubrectsColoured) != 0) {		  for (int j = 0; j < nSubrects; j++) {		    rfb.is.readFully(buf, 0, 4);		    fg = new Color((buf[2] & 0xFF) << 16 |				   (buf[1] & 0xFF) << 8 |				   (buf[0] & 0xFF));		    b1 = rfb.is.readUnsignedByte();		    b2 = rfb.is.readUnsignedByte();		    sx = tx + (b1 >> 4);		    sy = ty + (b1 & 0xf);		    sw = (b2 >> 4) + 1;		    sh = (b2 & 0xf) + 1;		    memGraphics.setColor(fg);		    memGraphics.fillRect(sx, sy, sw, sh);		  }		} else {		  memGraphics.setColor(fg);		  for (int j = 0; j < nSubrects; j++) {		    b1 = rfb.is.readUnsignedByte();		    b2 = rfb.is.readUnsignedByte();		    sx = tx + (b1 >> 4);		    sy = ty + (b1 & 0xf);		    sw = (b2 >> 4) + 1;		    sh = (b2 & 0xf) + 1;		    memGraphics.fillRect(sx, sy, sw, sh);		  }		}	      }	      // Finished with a row of tiles, now let's show it.	      scheduleRepaint(rx, ty, rw, th);	    }	    break;	  }	  case RfbProto.EncodingZlib:	  {	    int nBytes = rfb.is.readInt();            if (zlibBuf == null || zlibBufLen < nBytes) {              zlibBufLen = nBytes * 2;              zlibBuf = new byte[zlibBufLen];            }            rfb.is.readFully(zlibBuf, 0, nBytes);            zlibInflater.setInput(zlibBuf, 0, nBytes);            handleZlibRect(rfb.updateRectX, rfb.updateRectY,			   rfb.updateRectW, rfb.updateRectH);	    break;	  }	  case RfbProto.EncodingTight:	  {	    handleTightRect(rfb.updateRectX, rfb.updateRectY,			    rfb.updateRectW, rfb.updateRectH);	    break;	  }	  default:	    throw new IOException("Unknown RFB rectangle encoding " +				  rfb.updateRectEncoding);	  }	}	break;      case RfbProto.SetColourMapEntries:	throw new IOException("Can't handle SetColourMapEntries message");      case RfbProto.Bell:        Toolkit.getDefaultToolkit().beep();	break;      case RfbProto.ServerCutText:	String s = rfb.readServerCutText();	break;      default:	throw new IOException("Unknown RFB message type " + msgType);      }      if (player.getMode() == player.MODE_STOPPED) {	throw new EOFException("Playback stopped");      }    }  }