public VncReadMessageBody ReadServerMessage() { if (m_readingServerMessage) { return(null); } m_readingServerMessage = true; try { var readBody = VncComm.ReadServerMessage(m_readStream, m_serverInitBody.ServerPixelFormat.BytesPerPixel, m_serverInitBody.ServerPixelFormat.BigEndianFlag); // Set after WriteFramebufferUpdateRequest to prevent the excess data VncReadMessageBody retBody = null; var messageType = (VncEnum.MessageTypeServerToClient)readBody[0]; if (messageType == VncEnum.MessageTypeServerToClient.FramebufferUpdate) { var encodeList = VncEncodeFactory.CreateVncEncodeFromBinary(readBody, m_serverInitBody.ServerPixelFormat.BytesPerPixel, m_serverInitBody.ServerPixelFormat.BigEndianFlag, m_zrleReader); // Draw to canvas lock (CanvasLock) { foreach (var e in encodeList) { // Draw to canvas IVncPixelGetter pixelGetter = (e.EncodeType == VncEnum.EncodeType.ZRLE) ? m_pixelGetterZrle : m_pixelGetterNormal; e.Draw(pixelGetter, m_canvas); } } retBody = new VncReadMessageBody(messageType, encodeList, null); } else if (messageType == VncEnum.MessageTypeServerToClient.SetColorMapEntries) { var colorMap = new VncSetColorMapEntriesBody(readBody); m_pixelGetterNormal.SetColorMap(colorMap); retBody = new VncReadMessageBody(messageType, null, colorMap); } onRead(new VncReadEventArgs(readBody, retBody)); return(retBody); } catch (Exception a_ex) { cleanupForDisconnect(a_ex); onDisconnected(new VncCauseEventArgs(a_ex)); return(null); } finally { m_readingServerMessage = false; } }
public void SetColorMap(VncSetColorMapEntriesBody a_colorMap) { // If TrueColorFlag is false, m_colorMap is null at the first. if (m_colorMap == null) { m_colorMap = new Vec3b[0xFF + 1]; } // Set new color int index = a_colorMap.FirstColor; foreach (var rgb in a_colorMap.GetColors()) { m_colorMap[index] = new Vec3b((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); } }
public void SetColorMap(VncSetColorMapEntriesBody a_colorMap) { // If TrueColorFlag is false, m_colorMap is null at the first. if (m_colorMap == null) { m_colorMap = new Vec3b[SIZE * SIZE]; } // Set new color int index = a_colorMap.FirstColor; foreach (var rgb in a_colorMap.GetColors()) { int x = index >> 8; int y = index & 0xFF; m_colorMap[x * SIZE + y] = new Vec3b((byte)rgb.R, (byte)rgb.G, (byte)rgb.B); ++index; } }
public VncReadMessageBody(VncEnum.MessageTypeServerToClient a_messageType, List <VncEncodeAbstract> a_encodeList, VncSetColorMapEntriesBody a_colorMap) { MessageType = a_messageType; EncodeList = a_encodeList; ColorMap = a_colorMap; }
public void SetColorMap(VncSetColorMapEntriesBody a_colorMap) { throw new NotSupportedException($"VncPixelGetter32bits doe's not support SetColorMap."); }