Example #1
0
        readonly int pixelCount; // The total number of pixels (w x h) assigned in SetSize()


        /// <summary>
        /// Creates a new Framebuffer with (width x height) pixels.
        /// </summary>
        /// <param name="width">The width in pixels of the remote desktop.</param>
        /// <param name="height">The height in pixels of the remote desktop.</param>
        public Framebuffer(int width, int height)
        {
            infos = new FrameBufferInfos(width, height);


            // Cache the total size of the pixel array and initialize
            pixelCount = width * height;
            pixels     = new int[pixelCount];
        }
Example #2
0
        /// <summary>
        /// Given the dimensions and 16-byte PIXEL_FORMAT record from the VNC Host, deserialize this into a Framebuffer object.
        /// </summary>
        /// <param name="b">The 16-byte PIXEL_FORMAT record.</param>
        /// <param name="width">The width in pixels of the remote desktop.</param>
        /// <param name="height">The height in pixles of the remote desktop.</param>
        /// <returns>Returns a Framebuffer object matching the specification of b[].</returns>
        public static FrameBufferInfos FromPixelFormat(byte[] b, int width, int height)
        {
            if (b.Length != 16)
            {
                throw new ArgumentException("Length of b must be 16 bytes.");
            }

            FrameBufferInfos infos = new FrameBufferInfos(width, height);

            infos.BitsPerPixel = (int)b[0];
            infos.Depth        = (int)b[1];
            infos.BigEndian    = (b[2] != 0);
            infos.TrueColour   = (b[3] != 0);
            infos.RedMax       = (int)(b[5] | b[4] << 8);
            infos.GreenMax     = (int)(b[7] | b[6] << 8);
            infos.BlueMax      = (int)(b[9] | b[8] << 8);
            infos.RedShift     = (int)b[10];
            infos.GreenShift   = (int)b[11];
            infos.BlueShift    = (int)b[12];
            // Last 3 bytes are padding, ignore

            return(infos);
        }