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


C# BitMatrix.getTopLeftOnBit方法代码示例

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


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

示例1: 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.
      ///
      /// @see com.google.zxing.pdf417.PDF417Reader#extractPureBits(BitMatrix)
      /// @see com.google.zxing.qrcode.QRCodeReader#extractPureBits(BitMatrix)
      /// </summary>
      private static BitMatrix extractPureBits(BitMatrix image)
      {
         int[] leftTopBlack = image.getTopLeftOnBit();
         int[] rightBottomBlack = image.getBottomRightOnBit();
         if (leftTopBlack == null || rightBottomBlack == null)
         {
            return null;
         }

         int moduleSize;
         if (!DataMatrixReader.moduleSize(leftTopBlack, image, out moduleSize))
            return null;

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

         int matrixWidth = (right - left + 1) / moduleSize;
         int matrixHeight = (bottom - top + 1) / moduleSize;
         if (matrixWidth <= 0 || matrixHeight <= 0)
         {
            return null;
         }

         // 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[left + x * moduleSize, iOffset])
               {
                  bits[x, y] = true;
               }
            }
         }
         return bits;
      }
开发者ID:GSerjo,项目名称:Seminars,代码行数:56,代码来源:DataMatrixReader.cs

示例2: 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.
      /// 
      /// <seealso cref="ZXing.PDF417.PDF417Reader.extractPureBits(BitMatrix)" />
      /// <seealso cref="ZXing.Datamatrix.DataMatrixReader.extractPureBits(BitMatrix)" />
      /// </summary>
      private static BitMatrix extractPureBits(BitMatrix image)
      {
         int[] leftTopBlack = image.getTopLeftOnBit();
         int[] rightBottomBlack = image.getBottomRightOnBit();
         if (leftTopBlack == null || rightBottomBlack == null)
         {
            return null;
         }

         float moduleSize;
         if (!QRCodeReader.moduleSize(leftTopBlack, image, out moduleSize))
            return null;

         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)
         {
            return null;
         }
         if (matrixHeight != matrixWidth)
         {
            // Only possibly decode square regions
            return null;
         }

         // 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[left + (int)(x * moduleSize), iOffset])
               {
                  bits[x, y] = true;
               }
            }
         }
         return bits;
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:68,代码来源:QRCodeReader.cs

示例3: 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.
      /// 
      /// <seealso cref="ZXing.Datamatrix.DataMatrixReader.extractPureBits(BitMatrix)" />
      /// </summary>
      private static BitMatrix extractPureBits(BitMatrix image)
      {
         int[] leftTopBlack = image.getTopLeftOnBit();
         int[] rightBottomBlack = image.getBottomRightOnBit();
         if (leftTopBlack == null || rightBottomBlack == null)
         {
            return null;
         }

         float moduleSize;
         if (!QRCodeReader.moduleSize(leftTopBlack, image, out moduleSize))
            return null;

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

         // Sanity check!
         if (left >= right || top >= bottom)
         {
            return null;
         }

         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)
         {
            return null;
         }
         if (matrixHeight != matrixWidth)
         {
            // Only possibly decode square regions
            return null;
         }

         // 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;

         // But careful that this does not sample off the edge
         // "right" is the farthest-right valid pixel location -- right+1 is not necessarily
         // This is positive by how much the inner x loop below would be too large
         int nudgedTooFarRight = left + (int)((matrixWidth - 1) * moduleSize) - right;
         if (nudgedTooFarRight > 0)
         {
            if (nudgedTooFarRight > nudge)
            {
               // Neither way fits; abort
               return null;
            }
            left -= nudgedTooFarRight;
         }
         // See logic above
         int nudgedTooFarDown = top + (int)((matrixHeight - 1) * moduleSize) - bottom;
         if (nudgedTooFarDown > 0)
         {
            if (nudgedTooFarDown > nudge)
            {
               // Neither way fits; abort
               return null;
            }
            top -= nudgedTooFarDown;
         }

         // 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[left + (int)(x * moduleSize), iOffset])
               {
                  bits[x, y] = true;
               }
            }
         }
         return bits;
      }
开发者ID:arumata,项目名称:zxingnet,代码行数:98,代码来源:QRCodeReader(2).cs


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