Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  1. double wieksze(double x)
  2.         {
  3.             if (x > 255)
  4.             {
  5.                 return 255;
  6.             }
  7.             else return x;
  8.         }
  9.         private void trackBar5_Scroll(object sender, EventArgs e)
  10.         {
  11.            
  12.             textBox5.Text = Convert.ToString(trackBar5.Value);
  13.             if (opened)
  14.             {
  15.                 double wart = trackBar5.Value;
  16.                 if (wart > 0) { wart = wart / 10; }
  17.                 else{ wart = 0; }
  18.  
  19.                 Bitmap set = (Bitmap)pictureBox1.Image;
  20.                 pictureBox2.Image = new Bitmap(pictureBox2.Image);
  21.                 double stretch_X = set.Width / (double)pictureBox1.Width;
  22.                 double stretch_Y = set.Height / (double)pictureBox1.Height;
  23.  
  24.                 for (int i = 0; i < set.Height; i++)
  25.                 {
  26.                     for (int j = 0; j < set.Width; j++)
  27.                     {
  28.                      
  29.  
  30.                         Color piksel = myBitmap.GetPixel(j, i);
  31.  
  32.                         int r = Convert.ToInt16(piksel.R);
  33.                         int g = Convert.ToInt16(piksel.G);
  34.                         int b = Convert.ToInt16(piksel.B);
  35.  
  36. if(r<2) { r = 2; }
  37.                         if (g < 2) { g = 2; }
  38.                         if (b < 2) { b = 2; }
  39.  
  40.                         r = (int)(wieksze(Math.Pow(r, wart)));
  41.                         g = (int)(wieksze(Math.Pow(g, wart)));
  42.                         b = (int)(wieksze(Math.Pow(b, wart)));
  43.  
  44.                        
  45.                        
  46.  
  47.  
  48.                        ((Bitmap)pictureBox2.Image).SetPixel(j, i, System.Drawing.Color.FromArgb(r, g, b));
  49.                     }
  50.                 }
  51.             }
  52.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement