示例#1
0
        private void init(Bitmap pic)
        {
            this.bp = ImageEffect.Gray(pic);

            for (int ii = 0; ii < imageWidth; ii++)
            {
                for (int jj = 0; jj < imageHeight; jj++)
                {
                    if (bp.GetPixel(ii, jj).ToArgb() == Color.Black.ToArgb())
                    {
                        picPixel[ii, jj] = true;
                    }
                }
            }

            int  indexnum = 0;
            bool black    = false;

            for (int ii = 0; ii < imageWidth; ii++)
            {
                if (indexnum >= imageCount * 2)
                {
                    return;
                }
                bool haveblack = false;
                for (int jj = 0; jj < imageHeight; jj++)
                {
                    if (picPixel[ii, jj])
                    {
                        haveblack = true;
                        break;
                    }
                }
                if (haveblack && black == false)
                {
                    index[indexnum] = ii;
                    indexnum++;
                    black = true;
                }
                if (!haveblack && black)
                {
                    index[indexnum] = ii;
                    indexnum++;
                    black = false;
                }
            }
            if (indexnum < imageCount * 2 - 1)
            {
                return;
            }
            if (indexnum == imageCount * 2 - 1)
            {
                index[imageCount * 2 - 1] = imageWidth;
            }
        }
示例#2
0
        private void init(Bitmap pic)
        {
            this.bp = ImageEffect.Gray(pic);

            if (OCR2.dataP == null)
            {
                OCR2.dataP = new int[10000, bp.Height];
            }
            datapic  = new int[bp.Height];
            picPixel = new bool[bp.Width, bp.Height];
            for (int ii = 0; ii < bp.Width; ii++)
            {
                for (int jj = 0; jj < bp.Height; jj++)
                {
                    if (bp.GetPixel(ii, jj).ToArgb() == Color.Black.ToArgb())
                    {
                        picPixel[ii, jj] = true;
                    }
                }
            }
        }