コード例 #1
0
        private void HighlightWord(Graphics g, int zoneIndex, int wordIndex, Brush b, Pen p)
        {
            OcrWord word = _ocrZoneWords[zoneIndex][wordIndex];

            // Get the word bounding rectangle and convert to physical so we can draw it on the viewer surface
            LeadRect rc = LeadRectD.FromLTRB(word.Bounds.Left, word.Bounds.Top, word.Bounds.Right, word.Bounds.Bottom).ToLeadRect();

            rc = _imageViewer.ConvertRect(null, ImageViewerCoordinateType.Image, ImageViewerCoordinateType.Control, rc);

            // Make the rectangle a little bit bigger for visibility purposes
            rc.Inflate(_wordEdge, _wordEdge);

            g.FillRectangle(b, Leadtools.Demos.Converters.ConvertRect(rc));
            g.DrawRectangle(p, rc.X, rc.Y, rc.Width - 1, rc.Height - 1);
        }
コード例 #2
0
        private static RasterImage GetCroppedImage(RasterImage input, LeadRect boundaries)
        {
            boundaries.Inflate(INFLATE, INFLATE);

            RasterImage target = null;

            try
            {
                target = input.Clone();

                CropCommand cc = new CropCommand();
                cc.Rectangle = boundaries;
                cc.Run(target);
            }
            catch (Exception)
            {
                return(null);
            }
            return(target);
        }