public string decode(Bitmap bmp, LetterFont compareFont) { string decodeString = ""; using (UnsafeBitmap ubm = new UnsafeBitmap(bmp)) { ubm.LockBitmap(); for (int i = 0; i < ubm.Bitmap.Height - compareFont.charHeight + 1; i++) { int lastCol = 0; for (int j = 0; j < ubm.Bitmap.Width; j++) { Letter letter = compareFont.findLetter(ubm, j, i, lastCol > 0); if (letter != null) { int padding = (j - lastCol) / compareFont.spaceWidth; for (int k = 0; k < padding; k++) { decodeString += " "; } decodeString += letter.convertString; j += letter.ubm.Bitmap.Width - 1; lastCol = j + 1; } } if (lastCol > 0) { decodeString += "\r\n"; i += compareFont.charHeight - 1; } } } return(decodeString.Trim()); }
public string decode(Bitmap bmp, LetterFont compareFont) { string decodeString = ""; using (UnsafeBitmap ubm = new UnsafeBitmap(bmp)) { ubm.LockBitmap(); for (int i = 0; i < ubm.Bitmap.Height - compareFont.charHeight + 1; i++) { int lastCol = 0; for (int j = 0; j < ubm.Bitmap.Width; j++) { Letter letter = compareFont.findLetter(ubm, j, i, lastCol > 0); if (letter != null) { int padding = (j - lastCol) / compareFont.spaceWidth; for (int k = 0; k < padding; k++) { decodeString += " "; } decodeString += letter.convertString; j += letter.ubm.Bitmap.Width - 1; lastCol = j + 1; } } if (lastCol > 0) { decodeString += "\r\n"; i += compareFont.charHeight - 1; } } } return decodeString.Trim(); }