Guest User

Untitled

a guest
Dec 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1.  
  2.         void Medin(ref Color col,int x,int y,int h,int w)
  3.         {
  4.             Color c; int p = 0; int X, Y;
  5.             int[] rg, bg, gg;
  6.             rg = new int[9]; bg = new int[9]; gg = new int[9];
  7.             for (int i = -1; i <= 1; ++i)
  8.             {
  9.  
  10.                 for (int j = -1; j <= 1; ++j)
  11.                 {
  12.                     X = x + j; Y = y + i;
  13.                     if (x + j >= w) X = x-j;
  14.                     if (x + j < 0) X = x-j;
  15.                     if (y + i >= h) Y = y-i;
  16.                     if (y + i < 0) Y = y-i;
  17.  
  18.                     c = bmp.GetPixel(X, Y);
  19.                     rg[p] = c.R;
  20.                     bg[p] = c.B;
  21.                     gg[p]=c.G;
  22.                     ++p;
  23.                  }
  24.                  }
  25.             Array.Sort(rg); Array.Sort(bg); Array.Sort(gg);
  26.             col = Color.FromArgb(rg[4], gg[4], bg[4]);
  27.         }
Add Comment
Please, Sign In to add comment