Beispiel #1
0
        private List <string> DecodeImage(Bitmap image, int maxResultCount, TimeSpan timeOut, bool isMosaic)
        {
            List <string> result = new List <string>();
            int           stride;

            byte[]    rawImg  = ImageToByteArray(image, out stride);
            DmtxImage dmtxImg = new DmtxImage(rawImg, image.Width, image.Height, DmtxPackOrder.DmtxPack24bppRGB);

            dmtxImg.RowPadBytes = stride % 3;
            DmtxDecode decode    = new DmtxDecode(dmtxImg, 1);
            TimeSpan   timeLeft  = new TimeSpan(timeOut.Ticks);
            Stopwatch  stopWatch = new Stopwatch();

            stopWatch.Start();
            while (true)
            {
                if (stopWatch.Elapsed > timeOut)
                {
                    break;
                }
                DmtxRegion region = decode.RegionFindNext(timeOut);
                if (region != null)
                {
                    DmtxMessage msg     = isMosaic ? decode.MosaicRegion(region, -1) : decode.MatrixRegion(region, -1);
                    string      message = Encoding.ASCII.GetString(msg.Output);
                    message = message.Substring(0, message.IndexOf('\0'));
                    if (!result.Contains(message))
                    {
                        result.Add(message);
                        if (result.Count >= maxResultCount)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }
            return(result);
        }
Beispiel #2
0
 internal DmtxRegion(DmtxRegion src)
 {
     this._bottomAngle = src._bottomAngle;
     this._bottomKnown = src._bottomKnown;
     this._bottomLine = src._bottomLine;
     this._bottomLoc = src._bottomLoc;
     this._boundMax = src._boundMax;
     this._boundMin = src._boundMin;
     this._finalNeg = src._finalNeg;
     this._finalPos = src._finalPos;
     this._fit2raw = new DmtxMatrix3(src._fit2raw);
     this._flowBegin = src._flowBegin;
     this._jumpToNeg = src._jumpToNeg;
     this._jumpToPos = src._jumpToPos;
     this._leftAngle = src._leftAngle;
     this._leftKnown = src._leftKnown;
     this._leftLine = src._leftLine;
     this._leftLoc = src._leftLoc;
     this._locR = src._locR;
     this._locT = src._locT;
     this._mappingCols = src._mappingCols;
     this._mappingRows = src._mappingRows;
     this._offColor = src._offColor;
     this._onColor = src._onColor;
     this._polarity = src._polarity;
     this._raw2fit = new DmtxMatrix3(src._raw2fit);
     this._rightAngle = src._rightAngle;
     this._rightKnown = src._rightKnown;
     this._rightLoc = src._rightLoc;
     this._sizeIdx = src._sizeIdx;
     this._stepR = src._stepR;
     this._stepsTotal = src._stepsTotal;
     this._stepT = src._stepT;
     this._symbolCols = src._symbolCols;
     this._symbolRows = src._symbolRows;
     this._topAngle = src._topAngle;
     this._topKnown = src._topKnown;
     this._topLoc = src._topLoc;
 }
Beispiel #3
0
 internal DmtxRegion(DmtxRegion src)
 {
     this._bottomAngle = src._bottomAngle;
     this._bottomKnown = src._bottomKnown;
     this._bottomLine  = src._bottomLine;
     this._bottomLoc   = src._bottomLoc;
     this._boundMax    = src._boundMax;
     this._boundMin    = src._boundMin;
     this._finalNeg    = src._finalNeg;
     this._finalPos    = src._finalPos;
     this._fit2raw     = new DmtxMatrix3(src._fit2raw);
     this._flowBegin   = src._flowBegin;
     this._jumpToNeg   = src._jumpToNeg;
     this._jumpToPos   = src._jumpToPos;
     this._leftAngle   = src._leftAngle;
     this._leftKnown   = src._leftKnown;
     this._leftLine    = src._leftLine;
     this._leftLoc     = src._leftLoc;
     this._locR        = src._locR;
     this._locT        = src._locT;
     this._mappingCols = src._mappingCols;
     this._mappingRows = src._mappingRows;
     this._offColor    = src._offColor;
     this._onColor     = src._onColor;
     this._polarity    = src._polarity;
     this._raw2fit     = new DmtxMatrix3(src._raw2fit);
     this._rightAngle  = src._rightAngle;
     this._rightKnown  = src._rightKnown;
     this._rightLoc    = src._rightLoc;
     this._sizeIdx     = src._sizeIdx;
     this._stepR       = src._stepR;
     this._stepsTotal  = src._stepsTotal;
     this._stepT       = src._stepT;
     this._symbolCols  = src._symbolCols;
     this._symbolRows  = src._symbolRows;
     this._topAngle    = src._topAngle;
     this._topKnown    = src._topKnown;
     this._topLoc      = src._topLoc;
 }