Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Main(string[] args)
- {
- path = @"D:\Universität\Visual Studio Projects\Console Apps\PictureInvert\PictureInvert\ae86.png";
- Init();
- }
- private static void Init()
- {
- // Initialize Bitmap into variable bmp
- bmp = new Bitmap(path);
- Invert();
- // Save the Bitmap
- Save();
- }
- private static void Save()
- {
- string[] str = path.Split(".");
- bmp.Save(str[0] + "_INV." + str[1]);
- }
- private static void Invert()
- {
- int w = bmp.Width;
- int h = bmp.Height;
- Color color;
- byte r, g, b;
- // Invert matrix
- for (int y = 0; y < h; y++)
- {
- for (int x = 0; x < w; x++)
- {
- color = bmp.GetPixel(x, y);
- r = color.R;
- g = color.G;
- b = color.B;
- bmp.SetPixel(x, y, Color.FromArgb(255 - r, 255 - g, 255 - b));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement