Инверсия изображения


public Bitmap Invert(Bitmap bitmap)
{
    //X Axis
    int x;
    //Y Axis
    int y;
    //For the Width
    for (x = 0; x <= bitmap.Width - 1; x++)
    {
        //For the Height
        for (y = 0; y <= bitmap.Height - 1; y += 1)
        {
            //The Old Color to Replace
            Color oldColor = bitmap.GetPixel(x, y);
            //The New Color to Replace the Old Color
            Color newColor;
            //Set the Color for newColor
            newColor = Color.FromArgb(oldColor.A, 255 - oldColor.R, 255 - oldColor.G, 255 - oldColor.B);
            //Replace the Old Color with the New Color
            bitmap.SetPixel(x, y, newColor);
        }
    }
    //Return the Inverted Bitmap
    return bitmap;
}

Комментариев нет:

Отправить комментарий

Большая просьба, не писать в комментариях всякую ерунду не по теме!