Exemple #1
0
        private void Math_Add()
        {
            x             = BitmapO2.Width;
            y             = BitmapO2.Height;
            int[,,] color = new int[3, x, y];
            int start = 1;

            //叠加原图
            for (int i = start; i < x - start; i++)
            {
                for (int j = start; j < y - start; j++)
                {
                    Color pixR = BitmapO2.GetPixel(i, j);
                    Color pixO = BitmapOrigin.GetPixel(i, j);
                    color[0, i, j] = (int)(pixR.R * c1 - pixO.R * c);
                    color[1, i, j] = (int)(pixR.G * c1 - pixO.G * c);
                    color[2, i, j] = (int)(pixR.B * c1 - pixO.B * c);
                }
            }
            for (int i = start; i < x - start; i++)
            {
                for (int j = start; j < y - start; j++)
                {
                    for (int c = 0; c < 3; c++)
                    {
                        color[c, i, j] = color[c, i, j] > 255 ? 255 : color[c, i, j];
                        color[c, i, j] = color[c, i, j] < 0 ? 0 : color[c, i, j];
                    }
                }
            }
            //color = RealBD(color);
            bitmapResult = new Bitmap(x, y);
            for (int i = start; i < x - start; i++)
            {
                for (int j = start; j < y - start; j++)
                {
                    bitmapResult.SetPixel(i, j, Color.FromArgb(color[0, i, j], color[1, i, j], color[2, i, j]));
                }
            }
        }
Exemple #2
0
 private void Math_MultiEvent()
 {
     if (BitmapOrigin.Size != BitmapO2.Size)
     {
         return;
     }
     x            = BitmapO2.Width;
     y            = BitmapO2.Height;
     bitmapResult = new Bitmap(x, y);
     for (int i = 0; i < bitmapResult.Width; i++)
     {
         for (int j = 0; j < bitmapResult.Height; j++)
         {
             var colorO = BitmapOrigin.GetPixel(i, j);
             var colorR = BitmapO2.GetPixel(i, j);
             int r      = colorO.R * colorR.R / 255;
             int g      = colorO.G * colorR.G / 255;
             int b      = colorO.B * colorR.B / 255;
             bitmapResult.SetPixel(i, j, Color.FromArgb(r, g, b));
         }
     }
 }