01.
public
Bitmap Transform(Bitmap source)
02.
{
03.
04.
Bitmap newBitmap =
new
Bitmap(source.Width, source.Height);
05.
06.
07.
Graphics g = Graphics.FromImage(newBitmap);
08.
09.
10.
ColorMatrix colorMatrix =
new
ColorMatrix();
11.
colorMatrix.Matrix00 = colorMatrix.Matrix11 = colorMatrix.Matrix22 = -1f;
12.
colorMatrix.Matrix33 = colorMatrix.Matrix44 = 1f;
13.
14.
15.
ImageAttributes attributes =
new
ImageAttributes();
16.
17.
attributes.SetColorMatrix(colorMatrix);
18.
19.
g.DrawImage(source,
new
Rectangle(0, 0, source.Width, source.Height),
20.
0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);
21.
22.
23.
g.Dispose();
24.
25.
return
newBitmap;
26.
}