当前位置: 首页>>代码示例>>C#>>正文


C# com.google.zxing.common.BitMatrix.get方法代码示例

本文整理汇总了C#中com.google.zxing.common.BitMatrix.get方法的典型用法代码示例。如果您正苦于以下问题:C# com.google.zxing.common.BitMatrix.get方法的具体用法?C# com.google.zxing.common.BitMatrix.get怎么用?C# com.google.zxing.common.BitMatrix.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.zxing.common.BitMatrix的用法示例。


在下文中一共展示了com.google.zxing.common.BitMatrix.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getModuleSize

        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private static int moduleSize(int[] leftTopBlack, com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
        private static int getModuleSize(int[] leftTopBlack, BitMatrix image)
        {
            int x = leftTopBlack[0];
            int y = leftTopBlack[1];
            int width = image.Width;
            while (x < width && image.get(x, y))
            {
              x++;
            }
            if (x == width)
            {
              throw NotFoundException.NotFoundInstance;
            }

            int moduleSize = (int)((uint)(x - leftTopBlack[0]) >> 3); // We've crossed left first bar, which is 8x
            if (moduleSize == 0)
            {
              throw NotFoundException.NotFoundInstance;
            }

            return moduleSize;
        }
开发者ID:barz,项目名称:zxing,代码行数:24,代码来源:PDF417Reader.cs

示例2: findPatternEnd

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: private static int findPatternEnd(int x, int y, com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
 private static int findPatternEnd(int x, int y, BitMatrix image)
 {
     int width = image.Width;
     int end = width - 1;
     // end should be on black
     while (end > x && !image.get(end, y))
     {
       end--;
     }
     int transitions = 0;
     bool black = true;
     while (end > x && transitions < 9)
     {
       end--;
       bool newBlack = image.get(end, y);
       if (black != newBlack)
       {
     transitions++;
       }
       black = newBlack;
     }
     if (end == x)
     {
       throw NotFoundException.NotFoundInstance;
     }
     return end;
 }
开发者ID:barz,项目名称:zxing,代码行数:29,代码来源:PDF417Reader.cs

示例3: findPatternStart

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: private static int findPatternStart(int x, int y, com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
 private static int findPatternStart(int x, int y, BitMatrix image)
 {
     int width = image.Width;
     int start = x;
     // start should be on black
     int transitions = 0;
     bool black = true;
     while (start < width - 1 && transitions < 8)
     {
       start++;
       bool newBlack = image.get(start, y);
       if (black != newBlack)
       {
     transitions++;
       }
       black = newBlack;
     }
     if (start == width - 1)
     {
       throw NotFoundException.NotFoundInstance;
     }
     return start;
 }
开发者ID:barz,项目名称:zxing,代码行数:25,代码来源:PDF417Reader.cs

示例4: extractPureBits

        /// <summary>
        /// This method detects a code in a "pure" image -- that is, pure monochrome image
        /// which contains only an unrotated, unskewed, image of a code, with some white border
        /// around it. This is a specialized method that works exceptionally fast in this special
        /// case.
        /// </summary>
        /// <seealso cref= com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix) </seealso>
        /// <seealso cref= com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix) </seealso>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private static com.google.zxing.common.BitMatrix extractPureBits(com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
        private static BitMatrix extractPureBits(BitMatrix image)
        {
            int[] leftTopBlack = image.TopLeftOnBit;
            int[] rightBottomBlack = image.BottomRightOnBit;
            if (leftTopBlack == null || rightBottomBlack == null)
            {
              throw NotFoundException.NotFoundInstance;
            }

            int moduleSize = getModuleSize(leftTopBlack, image);

            int top = leftTopBlack[1];
            int bottom = rightBottomBlack[1];
            int left = findPatternStart(leftTopBlack[0], top, image);
            int right = findPatternEnd(leftTopBlack[0], top, image);

            int matrixWidth = (right - left + 1) / moduleSize;
            int matrixHeight = (bottom - top + 1) / moduleSize;
            if (matrixWidth <= 0 || matrixHeight <= 0)
            {
              throw NotFoundException.NotFoundInstance;
            }

            // Push in the "border" by half the module width so that we start
            // sampling in the middle of the module. Just in case the image is a
            // little off, this will help recover.
            int nudge = moduleSize >> 1;
            top += nudge;
            left += nudge;

            // Now just read off the bits
            BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
            for (int y = 0; y < matrixHeight; y++)
            {
              int iOffset = top + y * moduleSize;
              for (int x = 0; x < matrixWidth; x++)
              {
            if (image.get(left + x * moduleSize, iOffset))
            {
              bits.set(x, y);
            }
              }
            }
            return bits;
        }
开发者ID:barz,项目名称:zxing,代码行数:55,代码来源:PDF417Reader.cs

示例5: getModuleSize

        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private static int moduleSize(int[] leftTopBlack, com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
        private static int getModuleSize(int[] leftTopBlack, BitMatrix image)
        {
            int width = image.Width;
            int x = leftTopBlack[0];
            int y = leftTopBlack[1];
            while (x < width && image.get(x, y))
            {
              x++;
            }
            if (x == width)
            {
              throw NotFoundException.NotFoundInstance;
            }

            int moduleSize = x - leftTopBlack[0];
            if (moduleSize == 0)
            {
              throw NotFoundException.NotFoundInstance;
            }
            return moduleSize;
        }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:23,代码来源:DataMatrixReader.cs

示例6: getModuleSize

 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: private static float moduleSize(int[] leftTopBlack, com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
 private static float getModuleSize(int[] leftTopBlack, BitMatrix image)
 {
     int height = image.Height;
     int width = image.Width;
     int x = leftTopBlack[0];
     int y = leftTopBlack[1];
     bool inBlack = true;
     int transitions = 0;
     while (x < width && y < height)
     {
       if (inBlack != image.get(x, y))
       {
     if (++transitions == 5)
     {
       break;
     }
     inBlack = !inBlack;
       }
       x++;
       y++;
     }
     if (x == width || y == height)
     {
       throw NotFoundException.NotFoundInstance;
     }
     return (x - leftTopBlack[0]) / 7.0f;
 }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:29,代码来源:QRCodeReader.cs

示例7: extractPureBits

        /// <summary>
        /// This method detects a code in a "pure" image -- that is, pure monochrome image
        /// which contains only an unrotated, unskewed, image of a code, with some white border
        /// around it. This is a specialized method that works exceptionally fast in this special
        /// case.
        /// </summary>
        /// <seealso cref= com.google.zxing.pdf417.PDF417Reader#extractPureBits(BitMatrix) </seealso>
        /// <seealso cref= com.google.zxing.datamatrix.DataMatrixReader#extractPureBits(BitMatrix) </seealso>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private static com.google.zxing.common.BitMatrix extractPureBits(com.google.zxing.common.BitMatrix image) throws com.google.zxing.NotFoundException
        private static BitMatrix extractPureBits(BitMatrix image)
        {
            int[] leftTopBlack = image.TopLeftOnBit;
            int[] rightBottomBlack = image.BottomRightOnBit;
            if (leftTopBlack == null || rightBottomBlack == null)
            {
              throw NotFoundException.NotFoundInstance;
            }

            float moduleSize = getModuleSize(leftTopBlack, image);

            int top = leftTopBlack[1];
            int bottom = rightBottomBlack[1];
            int left = leftTopBlack[0];
            int right = rightBottomBlack[0];

            if (bottom - top != right - left)
            {
              // Special case, where bottom-right module wasn't black so we found something else in the last row
              // Assume it's a square, so use height as the width
              right = left + (bottom - top);
            }

            int matrixWidth = (int)Math.Round((right - left + 1) / moduleSize);
            int matrixHeight = (int) Math.Round((bottom - top + 1) / moduleSize);
            if (matrixWidth <= 0 || matrixHeight <= 0)
            {
              throw NotFoundException.NotFoundInstance;
            }
            if (matrixHeight != matrixWidth)
            {
              // Only possibly decode square regions
              throw NotFoundException.NotFoundInstance;
            }

            // Push in the "border" by half the module width so that we start
            // sampling in the middle of the module. Just in case the image is a
            // little off, this will help recover.
            int nudge = (int)(moduleSize / 2.0f);
            top += nudge;
            left += nudge;

            // Now just read off the bits
            BitMatrix bits = new BitMatrix(matrixWidth, matrixHeight);
            for (int y = 0; y < matrixHeight; y++)
            {
              int iOffset = top + (int)(y * moduleSize);
              for (int x = 0; x < matrixWidth; x++)
              {
            if (image.get(left + (int)(x * moduleSize), iOffset))
            {
              bits.set(x, y);
            }
              }
            }
            return bits;
        }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:67,代码来源:QRCodeReader.cs

示例8: extractDataRegion

        /// <summary>
        /// <p>Extracts the data region from a <seealso cref="BitMatrix"/> that contains
        /// alignment patterns.</p>
        /// </summary>
        /// <param name="bitMatrix"> Original <seealso cref="BitMatrix"/> with alignment patterns </param>
        /// <returns> BitMatrix that has the alignment patterns removed </returns>
        internal BitMatrix extractDataRegion(BitMatrix bitMatrix)
        {
            int symbolSizeRows = version.SymbolSizeRows;
            int symbolSizeColumns = version.SymbolSizeColumns;

            if (bitMatrix.Height != symbolSizeRows)
            {
              throw new System.ArgumentException("Dimension of bitMarix must match the version size");
            }

            int dataRegionSizeRows = version.DataRegionSizeRows;
            int dataRegionSizeColumns = version.DataRegionSizeColumns;

            int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
            int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;

            int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
            int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;

            BitMatrix bitMatrixWithoutAlignment = new BitMatrix(sizeDataRegionColumn, sizeDataRegionRow);
            for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow)
            {
              int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
              for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn)
              {
            int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns;
            for (int i = 0; i < dataRegionSizeRows; ++i)
            {
              int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i;
              int writeRowOffset = dataRegionRowOffset + i;
              for (int j = 0; j < dataRegionSizeColumns; ++j)
              {
                int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j;
                if (bitMatrix.get(readColumnOffset, readRowOffset))
                {
                  int writeColumnOffset = dataRegionColumnOffset + j;
                  bitMatrixWithoutAlignment.set(writeColumnOffset, writeRowOffset);
                }
              }
            }
              }
            }
            return bitMatrixWithoutAlignment;
        }
开发者ID:Th3Ya0vi,项目名称:GameHouseUniverse,代码行数:50,代码来源:BitMatrixParser.cs


注:本文中的com.google.zxing.common.BitMatrix.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。