private UnsafeBitmap GetReferenceCharBmp(UnsafeBitmap bmChars, int index) { if (index * 16 >= bmChars.Width) { return(null); } return(bmChars.Clone(new Rectangle(index * 16 + 1, 0, 15, bmChars.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb)); }
public BmpChar(UnsafeBitmap bmChar, char character) { this.character = character; bm = bmChar; if (bm == null) { return; } // Trim empty area from right side of reference bitmap int x = 0; // x = Utils.FindNextVerticalLine(bm, 0, Color.FromArgb(255, 255, 255, 255), true); x = bm.FindNextVerticalLine(0, Color.FromArgb(255, 255, 255), true); if (x > 0) { bm = bm.Clone(new Rectangle(0, 0, x, bm.Height), bm.PixelFormat); } charWidth = bm.Width; // Find character height int y = 0; for (y = 0; y < bm.Height && charTop <= 0; y++) { for (x = 0; x < bm.Width; x++) { if (bm.GetPixel(x, y) != Color.FromArgb(255, 255, 255)) { charTop = y; break; } } } for (y = bm.Height - 1; y >= 0 && charBottom <= 0; y--) { for (x = 0; x < bm.Width; x++) { if (bm.GetPixel(x, y) != Color.FromArgb(255, 255, 255)) { charBottom = y; break; } } } charHeight = charBottom - charTop + 1; }