Beispiel #1
0
        private void UnsafeSetPixelColor(int x, int y, ColorVector color)
        {
            unsafe
            {
                // Get a pointer to the back buffer.
                int pBackBuffer = (int)WriteableBitmap.BackBuffer;

                // Find the address of the pixel to draw.
                pBackBuffer += y * WriteableBitmap.BackBufferStride;
                pBackBuffer += x * 4;

                // Compute the pixel's color.
                var clamped   = color.Clamp();
                int colorData = ColorToInt(clamped.R) << 16; // R
                colorData |= ColorToInt(clamped.G) << 8;     // G
                colorData |= ColorToInt(clamped.B) << 0;     // B

                // Assign the color data to the pixel.
                *((int *)pBackBuffer) = colorData;
            }
        }