Ejemplo n.º 1
0
        public virtual void SetPixel(int x, int y, IPixel pel)
        {
            // If the pixel types match, then 
            PixelInformation pelInfo = new PixelInformation(pel.Layout, pel.ComponentType);
            if (PixRectInfo.GetPixelInformation().Equals(pelInfo))
            {
                // Find the byte offset for the pixel
                IntPtr pixelPtr = GetPixelPointer(x, y);

                // copy the color bytes into the array
                Marshal.Copy(pel.GetBytes(), 0, pixelPtr, pel.GetBytes().Length);
                return;
            }

            // If the pixel types don't match, then we have to go through
            // color instead of just copying the pixel directly.
            SetColor(x, y, Pixel.GetColor(pelInfo, pel.GetBytes()));

        }