Transferred from: http://www.it165.net/pro/html/201208/3469.html
Invert English is called Upside down. The principle is simply that it will be 255-the original value.
So 0 (black) will become 255 (white) and 255 (white) will become 0 (black)
So the formula is to subtract R, G, and B by 255.
You can get the reversal value, the reason for this effect needs to be related to the previous negative film has a positive root negative
Most of us use negative negatives to wash out the colors that turn out to be the same as the photos you see.
C # Code:
View Sourceprint?
01.
public
System.Drawing.Bitmap ConvertToInvert(System.Drawing.Image img) {
02.
// 读入欲转换的图片并转成为 WritableBitmap www.it165.net
03.
System.Drawing.Bitmap bitmap =
new
System.Drawing.Bitmap(img);
04.
for
(
int
y = 0; y < bitmap.Height; y++)
05.
{
06.
for
(
int
x = 0; x < bitmap.Width; x++)
07.
{
08.
// 取得每一个 pixel
09.
var pixel = bitmap.GetPixel(x, y);
10.
11.
// 负片效果 将其反转
12.
System.Drawing.Color newColor = System.Drawing.Color.FromArgb(pixel.A, 255 - pixel.R, 255 - pixel.G, 255 - pixel.B);
13.
14.
bitmap.SetPixel(x, y, newColor);
15.
16.
}
17.
}
18.
// 显示结果
19.
return
bitmap;
20.
}
Results:
C # Write Filter Picture tint counter effect (Invert)