Esempio n. 1
0
        /// <summary>
        /// Pastes a pixel map at the desired position.
        /// </summary>
        /// <param name="pixelMap">The pixel map to paste.</param>
        /// <param name="x">The horizontal coordinate to start pasting.</param>
        /// <param name="y">The vertical coordinate to start pasting.</param>
        public void Paste(PixelMap pixelMap, int originX, int originY)
        {
            // Iterate through the pixels horizontally.
            for (int x = 0; x < pixelMap.Width; x++)
            {
                // Iterate through the pixels vertically.
                for (int y = 0; y < pixelMap.Height; y++)
                {
                    // Calculate index.
                    int posX = originX + x;
                    int posY = originY + y;

                    // Set pixel if within bounds.
                    if (posX >= 0 && posY >= 0 && posX < _width && posY < _height)
                    {
                        _pixels[posX, posY] = pixelMap.Pixels[x, y];
                    }
                }
            }
        }