Exemplo n.º 1
0
 //Дорисуем кисточку по координате x, y
 private void AddBrush(MouseEventArgs e)
 {
     if (clickon)
     {
         int    R    = ps.Radius;
         byte[] C    = ps.GetColores();
         int    xpos = (int)(pictureBox1.Image.Width * (double)e.X / (double)pictureBox1.Width);
         int    ypos = (int)(pictureBox1.Image.Height * (double)e.Y / (double)pictureBox1.Height);
         for (int x = Math.Max(xpos - R, 0); x < Math.Min(pictureBox1.Image.Width - 1, xpos + R + 1); x++)
         {
             for (int y = Math.Max(0, ypos - R); y < Math.Min(pictureBox1.Image.Height - 1, ypos + R + 1); y++)
             {
                 if (Math.Sqrt((x - xpos) * (x - xpos) + (y - ypos) * (y - ypos)) <= R)
                 {
                     for (int j = 0; j < 3; j++)
                     {
                         if (C[j] != 0)
                         {
                             J.Data[y, x, j] = 255;
                         }
                         else
                         {
                             J.Data[y, x, j] = I.Data[y, x, j];
                         }
                         K.Data[y, x, j] = (byte)ps.TypeOrBrush;
                     }
                 }
             }
         }
     }
 }