CaptchaRecogition.ImageProcess.CutImage C# (CSharp) 메소드

CutImage() 공개 정적인 메소드

图片切割
public static CutImage ( int RowNum, int ColNum, Bitmap bm ) : System.Drawing.Bitmap[]
RowNum int
ColNum int
bm System.Drawing.Bitmap
리턴 System.Drawing.Bitmap[]
        public static Bitmap[] CutImage(int RowNum, int ColNum, Bitmap bm)
        {
            if (RowNum == 0 || ColNum == 0)
                return null;
            int singW = bm.Width / RowNum;
            int singH = bm.Height / ColNum;
            Bitmap[] PicArray = new Bitmap[RowNum * ColNum];

            Rectangle cloneRect;
            for (int i = 0; i < ColNum; i++) //找有效区
            {
                for (int j = 0; j < RowNum; j++)
                {
                    cloneRect = new Rectangle(j * singW, i * singH, singW, singH);
                    PicArray[i * RowNum + j] = GetPicValidByValue(bm.Clone(cloneRect, bm.PixelFormat), 128); //复制小块图
                }
            }
            return PicArray;

        }

Same methods

ImageProcess::CutImage ( Image img, int ww, int hh, bool is4Chars = true, int charWidth = 10 ) : List

Usage Example

예제 #1
0
        private void btn_cutImage_Click(object sender, EventArgs e)
        {
            //  Image img_cut =(Image) pb_gray_binary.Image.Clone();
            Image         img_cut = (Image)pb_noise_binary.Image.Clone();
            List <Bitmap> list    = ImageProcess.CutImage(img_cut, 20, 30, isFourChars, minWidth);

            cutResult = list;
            //  ccccccmd.ImageHandler handler = new ccccccmd.ImageHandler();
            //   List<Bitmap> list=     handler.CutImage(img_cut,56);
            //Bitmap[] list = ccccccmd.ImageHelper.CutImage(4,1,(Bitmap )img_cut);
            pb1.Image = list[0];
            if (list.Count >= 2)
            {
                pb2.Image = list[1];
            }
            else
            {
                pb2.Image = nullImg;
            }
            if (list.Count >= 3)
            {
                pb3.Image = list[2];
            }
            else
            {
                pb3.Image = nullImg;
            }
            if (list.Count >= 4)
            {
                pb4.Image = list[3];
            }
            else
            {
                pb4.Image = nullImg;
            }
            if (list.Count >= 5)
            {
                pb5.Image = list[4];
            }
            else
            {
                pb5.Image = nullImg;
            }
            if (list.Count >= 6)
            {
                pb6.Image = list[5];
            }
            else
            {
                pb6.Image = nullImg;
            }
        }