private static Rectangle letterRect(Bitmap source, int hStart, int hEnd)
{
int startWhite = -1, endWhite = -1;
for (int j = 0; j < source.Height; j++)
{
for (int i = hStart; i < hEnd; i++)
{
if (startWhite == -1 && source.GetPixel(i, j).R == 255)
{
startWhite = j;
}
if (endWhite == -1 && source.GetPixel(i, (source.Height - j) - 1).R == 255)
{
endWhite = (source.Height - j);
}
if (startWhite != -1 && endWhite != -1)
return new Rectangle(hStart, startWhite, hEnd - hStart, endWhite - startWhite);
}
}
return Rectangle.Empty;
}