Exemplo n.º 1
0
        private void RecognizeBarCode(BarCodeRule rule)
        {
            Pixbuf WorkImage = Images[0];

            RelationalRectangle WorkZone = rule.Box.Clone();

            WorkZone.SetTarget(WorkImage.Width, WorkImage.Height);

            logger.Debug("Зона штрихкода, box: x={0},y={1},w={2},h={3}", WorkZone.PosX, WorkZone.PosY, WorkZone.Width, WorkZone.Heigth);
            var cutedPixbuf = new Pixbuf(WorkImage, WorkZone.PosX, WorkZone.PosY, WorkZone.Width, WorkZone.Heigth);

            ShowImage(cutedPixbuf, "Зона штрихкода");

            // create a barcode reader instance
            IBarcodeReader reader = new BarcodeReader();
            // load a bitmap
            var barcodeBitmap = RecognizeHelper.PixbufToBitmap(cutedPixbuf);
            // detect and decode the barcode inside the bitmap
            var result = reader.Decode(barcodeBitmap);

            // do something with the result
            if (result != null)
            {
                logger.Debug("Формат штрих кода: {0}", result.BarcodeFormat.ToString());
                logger.Debug("Текст штрих кода разпознан как: {0}", result.Text);
                rule.ParseCode(Doc, result.BarcodeFormat, result.Text);
            }
            else
            {
                logger.Warn("Штрих код не распознан.");
            }
        }
Exemplo n.º 2
0
        private void RecognizeBarCode(BarCodeRule rule)
        {
            Pixbuf WorkImage = Images[0];

            RelationalRectangle WorkZone =  rule.Box.Clone();

            WorkZone.SetTarget(WorkImage.Width, WorkImage.Height);

            logger.Debug("Зона штрихкода, box: x={0},y={1},w={2},h={3}", WorkZone.PosX, WorkZone.PosY, WorkZone.Width, WorkZone.Heigth);
            var cutedPixbuf = new Pixbuf(WorkImage, WorkZone.PosX, WorkZone.PosY, WorkZone.Width, WorkZone.Heigth);

            ShowImage (cutedPixbuf, "Зона штрихкода");

            // create a barcode reader instance
            IBarcodeReader reader = new BarcodeReader();
            // load a bitmap
            var barcodeBitmap = RecognizeHelper.PixbufToBitmap (cutedPixbuf);
            // detect and decode the barcode inside the bitmap
            var result = reader.Decode(barcodeBitmap);
            // do something with the result
            if (result != null) {
                logger.Debug ("Формат штрих кода: {0}", result.BarcodeFormat.ToString ());
                logger.Debug ("Текст штрих кода разпознан как: {0}", result.Text);
                rule.ParseCode (Doc, result.BarcodeFormat, result.Text);
            } else
                logger.Warn ("Штрих код не распознан.");
        }