FriedrichLP

Untitled

Jun 29th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. redC = Int32.Parse(red.Text);
  2. greenC = Int32.Parse(green.Text);
  3. blueC = Int32.Parse(blue.Text);
  4.  
  5. Bitmap bitmap = new Bitmap(image);
  6.  
  7. //edit image
  8. List<int> list = new List<int>() { redC, greenC, blueC };
  9.  
  10. Random rnd = new Random();
  11. Color color = new Color();
  12. Color color2 = new Color();
  13. color = Color.FromArgb(255, redC, greenC, blueC);
  14.  
  15. for (int x = 0; x < bitmap.Width; x++) {
  16. for (int y = 0; y < bitmap.Height; y++) {
  17. if (bitmap.GetPixel(x, y) == color) {
  18. List<int> list2 = list;
  19. int max = list2.IndexOf(list2.Max());
  20. Console.WriteLine(list2.Max());
  21. Console.WriteLine(max);
  22. list2[max] += rnd.Next(-20, 20);
  23. if (list2[max] > 255) {
  24. list2[max] = 255;
  25. } else if (list2[max] < 0) {
  26. list2[max] = 0;
  27. }
  28. color2 = Color.FromArgb(255, list2[0], list2[1], list2[2]);
  29. bitmap.SetPixel(x, y, color2);
  30. }
  31. }
  32. }
  33.  
  34. pictureBox1.Image = bitmap;
Advertisement
Add Comment
Please, Sign In to add comment