public static Bitmap[][] GetLetters(Bitmap source, Rectangle textRec, Size letterSize, Size letterBorder) { int rows = (textRec.Height - letterSize.Height) / (letterSize.Height + letterBorder.Height) + 1; int cols = (textRec.Width - letterSize.Width) / (letterSize.Width - letterBorder.Width) + 1; Bitmap[][] bitmaps = new Bitmap[rows][]; int xIndex = 0; int yIndex = 0; for (int y = 0; y + letterSize.Height <= textRec.Height; y += letterSize.Height + letterBorder.Height) { bitmaps[yIndex] = new Bitmap[cols]; xIndex = 0; for (int x = 0; x + letterSize.Width <= textRec.Width; x += letterSize.Width + letterBorder.Width) { bitmaps[yIndex][xIndex] = OutputOCR.CropImage(source, new Rectangle(x, y, letterSize.Width, letterSize.Height)); xIndex++; } yIndex++; } return(bitmaps); }
private void pbImage_MouseDown(object sender, MouseEventArgs e) { Bitmap bm = new Bitmap(pbImage.Image); nudPixelX.Value = e.X; nudPixelY.Value = e.Y; plColor.BackColor = bm.GetPixel(e.X, e.Y); pbPreview.Image = OutputOCR.CropImage(bm, new Rectangle(e.X - 11, e.Y - 11, 21, 21)); PreviewColorDif(); }