Esempio n. 1
0
 /// <summary>
 ///     Fills the given Rectangle with pixel values read from the server (i.e., each pixel may have its own value).
 /// </summary>
 /// <param name="rect">The rectangle to be filled.</param>
 public void FillRectangle(Rectangle rect)
 {
     for (var y = rect.Y; y < rect.Y + rect.Height; ++y)
     {
         for (var x = rect.X; x < rect.X + rect.Width; ++x)
         {
             framebuffer[y * framebuffer.Width + x] = preader.ReadPixel(); // every pixel needs to be read from server
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Fills the given Rectangle with pixel values read from the server (i.e., each pixel may have its own value).
        /// </summary>
        /// <param name="rect">The rectangle to be filled.</param>
        protected void FillRectangle(Rectangle rect)
        {
            var ptr    = 0;
            var offset = 0;

            // If the two rectangles don't match, then rect is contained within rectangle, and
            // ptr and offset need to be adjusted to position things at the proper starting point.
            if (rect != rectangle)
            {
                ptr    = rect.Y * rectangle.Width + rect.X;                     // move to the start of the rectangle in pixels
                offset = rectangle.Width - rect.Width;                          // calculate the offset to get to the start of the next row
            }

            for (var y = 0; y < rect.Height; ++y)
            {
                for (var x = 0; x < rect.Width; ++x)
                {
                    Framebuffer[ptr++] = preader.ReadPixel();                           // every pixel needs to be read from server
                }
                ptr += offset;                                                          // advance to next row within pixels
            }
        }