public static Bitmap TrimBmp(Image img)
{
int[,] inputX = ConvertImgToArrayY(img);
int[,] inputY = ConvertImgToArrayX(img);
Point beyondX = GetXBeyond(inputX);
Point beyondY = GetYBeyond(inputY);
int w = beyondY.Y - beyondY.X + 1;
int h = beyondX.Y - beyondX.X + 1;
Bitmap bmp = new Bitmap(w, h);
for (int i = 0; i < h; i++)
{
int _y = i + beyondX.X;
for (int j = 0; j < w; j++)
{
int _x = j + beyondY.X;
int v = inputX[_y, _x];
if (v == 1)
{
bmp.SetPixel(j, i, Color.Black);
}
else
bmp.SetPixel(j, i, Color.White);
}
}
return bmp;
}