當前位置: 首頁>>代碼示例>>C#>>正文


C# Common.BitMatrix類代碼示例

本文整理匯總了C#中ZXing.Common.BitMatrix的典型用法代碼示例。如果您正苦於以下問題:C# BitMatrix類的具體用法?C# BitMatrix怎麽用?C# BitMatrix使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BitMatrix類屬於ZXing.Common命名空間,在下文中一共展示了BitMatrix類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Render

      public override Bitmap Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options)
      {
         int width = matrix.Width;
         int height = matrix.Height;

         var backgroundBrush = new LinearGradientBrush(
            new Rectangle(0, 0, width, height), BackgroundGradientColor, Background, LinearGradientMode.Vertical);
         var foregroundBrush = new LinearGradientBrush(
            new Rectangle(0, 0, width, height), ForegroundGradientColor, Foreground, LinearGradientMode.ForwardDiagonal);

         var bmp = new Bitmap(width, height);
         var gg = Graphics.FromImage(bmp);
         gg.Clear(Background);

         for (int x = 0; x < width - 1; x++)
         {
            for (int y = 0; y < height - 1; y++)
            {
               if (matrix[x, y])
               {
                  gg.FillRectangle(foregroundBrush, x, y, 1, 1);
               }
               else
               {
                  gg.FillRectangle(backgroundBrush, x, y, 1, 1);
               }
            }
         }

         return bmp;
      }
開發者ID:arumata,項目名稱:zxingnet,代碼行數:31,代碼來源:CustomBitmapRenderer.cs

示例2: sampleGrid

 public override BitMatrix sampleGrid(BitMatrix image, int dimensionX, int dimensionY, float p1ToX, float p1ToY, float p2ToX, float p2ToY, float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX, float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY)
 {
    PerspectiveTransform transform = PerspectiveTransform.quadrilateralToQuadrilateral(
       p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, 
       p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY);
    return sampleGrid(image, dimensionX, dimensionY, transform);
 }
開發者ID:Binjaaa,項目名稱:ZXing.Net.Mobile,代碼行數:7,代碼來源:DefaultGridSampler.cs

示例3: BinaryBitmap

 internal BinaryBitmap(BitMatrix matrix)
 {
    if (matrix == null)
    {
       throw new ArgumentException("matrix must be non-null.");
    }
    this.matrix = matrix;
 }
開發者ID:Binjaaa,項目名稱:ZXing.Net.Mobile,代碼行數:8,代碼來源:BinaryBitmap.cs

示例4: sampleGrid

      public override BitMatrix sampleGrid(BitMatrix image, int dimensionX, int dimensionY, PerspectiveTransform transform)
      {
         if (dimensionX <= 0 || dimensionY <= 0)
         {
            return null;
         }
         BitMatrix bits = new BitMatrix(dimensionX, dimensionY);
         float[] points = new float[dimensionX << 1];
         for (int y = 0; y < dimensionY; y++)
         {
            int max = points.Length;
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
            float iValue = (float)y + 0.5f;
            for (int x = 0; x < max; x += 2)
            {
               //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
               points[x] = (float)(x >> 1) + 0.5f;
               points[x + 1] = iValue;
            }
            transform.transformPoints(points);
            // Quick check to see if points transformed to something inside the image;
            // sufficient to check the endpoints
            if (!checkAndNudgePoints(image, points))
               return null;
            try
            {
               var imageWidth = image.Width;
               var imageHeight = image.Height;

               for (int x = 0; x < max; x += 2)
               {
                  var imagex = (int)points[x];
                  var imagey = (int)points[x + 1];

                  if (imagex < 0 || imagex >= imageWidth || imagey < 0 || imagey >= imageHeight)
                  {
                     return null;
                  }

                  bits[x >> 1, y] = image[imagex, imagey];
               }
            }
            catch (System.IndexOutOfRangeException)
            {
               // java version:
               // 
               // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting
               // transform gets "twisted" such that it maps a straight line of points to a set of points
               // whose endpoints are in bounds, but others are not. There is probably some mathematical
               // way to detect this about the transformation that I don't know yet.
               // This results in an ugly runtime exception despite our clever checks above -- can't have
               // that. We could check each point's coordinates but that feels duplicative. We settle for
               // catching and wrapping ArrayIndexOutOfBoundsException.
               return null;
            }
         }
         return bits;
      }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:58,代碼來源:DefaultGridSampler.cs

示例5: createBitMatrixParser

 /// <param name="bitMatrix">{@link BitMatrix} to parse</param>
 /// <throws>ReaderException if dimension is not >= 21 and 1 mod 4</throws>
 internal static BitMatrixParser createBitMatrixParser(BitMatrix bitMatrix)
 {
    int dimension = bitMatrix.Height;
    if (dimension < 21 || (dimension & 0x03) != 1)
    {
       return null;
    }
    return new BitMatrixParser(bitMatrix);
 }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:11,代碼來源:BitMatrixParser.cs

示例6: AztecDetectorResult

 /// <summary>
 /// Initializes a new instance of the <see cref="AztecDetectorResult"/> class.
 /// </summary>
 /// <param name="bits">The bits.</param>
 /// <param name="points">The points.</param>
 /// <param name="compact">if set to <c>true</c> [compact].</param>
 /// <param name="nbDatablocks">The nb datablocks.</param>
 /// <param name="nbLayers">The nb layers.</param>
 public AztecDetectorResult(BitMatrix bits,
                            ResultPoint[] points,
                            bool compact,
                            int nbDatablocks,
                            int nbLayers)
    : base(bits, points)
 {
    Compact = compact;
    NbDatablocks = nbDatablocks;
    NbLayers = nbLayers;
 }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:19,代碼來源:AztecDetectorResult.cs

示例7: unmaskBitMatrix

      /// <summary> <p>Implementations of this method reverse the data masking process applied to a QR Code and
      /// make its bits ready to read.</p>
      /// </summary>
      /// <param name="reference"></param>
      /// <param name="bits">representation of QR Code bits</param>
      /// <param name="dimension">dimension of QR Code, represented by bits, being unmasked</param>
      internal static void unmaskBitMatrix(int reference, BitMatrix bits, int dimension)
      {
         if (reference < 0 || reference > 7)
         {
            throw new System.ArgumentException();
         }

         var isMasked = DATA_MASKS[reference];

         bits.flipWhen(isMasked);
      }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:17,代碼來源:DataMask.cs

示例8: AlignmentPatternFinder

 /// <summary> <p>Creates a finder that will look in a portion of the whole image.</p>
 /// 
 /// </summary>
 /// <param name="image">image to search
 /// </param>
 /// <param name="startX">left column from which to start searching
 /// </param>
 /// <param name="startY">top row from which to start searching
 /// </param>
 /// <param name="width">width of region to search
 /// </param>
 /// <param name="height">height of region to search
 /// </param>
 /// <param name="moduleSize">estimated module size so far
 /// </param>
 internal AlignmentPatternFinder(BitMatrix image, int startX, int startY, int width, int height, float moduleSize, ResultPointCallback resultPointCallback)
 {
    this.image = image;
    this.possibleCenters = new List<AlignmentPattern>(5);
    this.startX = startX;
    this.startY = startY;
    this.width = width;
    this.height = height;
    this.moduleSize = moduleSize;
    this.crossCheckStateCount = new int[3];
    this.resultPointCallback = resultPointCallback;
 }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:27,代碼來源:AlignmentPatternFinder.cs

示例9: decode

 /// <summary>
 ///   <p>Convenience method that can decode a QR Code represented as a 2D array of booleans.
 /// "true" is taken to mean a black module.</p>
 /// </summary>
 /// <param name="image">booleans representing white/black QR Code modules</param>
 /// <param name="hints">The hints.</param>
 /// <returns>
 /// text and bytes encoded within the QR Code
 /// </returns>
 public DecoderResult decode(bool[][] image, IDictionary<DecodeHintType, object> hints)
 {
    int dimension = image.Length;
    BitMatrix bits = new BitMatrix(dimension);
    for (int i = 0; i < dimension; i++)
    {
       for (int j = 0; j < dimension; j++)
       {
          bits[j, i] = image[i][j];
       }
    }
    return decode(bits, hints);
 }
開發者ID:Bogdan-p,項目名稱:ZXing.Net,代碼行數:22,代碼來源:Decoder.cs

示例10: BoundingBox

 /// <summary>
 /// Initializes a new instance of the <see cref="ZXing.PDF417.Internal.BoundingBox"/> class.
 /// Will throw an exception if the corner points don't match up correctly
 /// </summary>
 /// <param name="image">Image.</param>
 /// <param name="topLeft">Top left.</param>
 /// <param name="topRight">Top right.</param>
 /// <param name="bottomLeft">Bottom left.</param>
 /// <param name="bottomRight">Bottom right.</param>
 private BoundingBox(BitMatrix image,
                     ResultPoint topLeft,
                     ResultPoint bottomLeft,
                     ResultPoint topRight,
                     ResultPoint bottomRight)
 {
    this.image = image;
    this.TopLeft = topLeft;
    this.TopRight = topRight;
    this.BottomLeft = bottomLeft;
    this.BottomRight = bottomRight;
    calculateMinMaxValues();
 }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:22,代碼來源:BoundingBox.cs

示例11: unmaskBitMatrix

 /// <summary> <p>Implementations of this method reverse the data masking process applied to a QR Code and
 /// make its bits ready to read.</p>
 /// 
 /// </summary>
 /// <param name="bits">representation of QR Code bits
 /// </param>
 /// <param name="dimension">dimension of QR Code, represented by bits, being unmasked
 /// </param>
 internal void unmaskBitMatrix(BitMatrix bits, int dimension)
 {
    for (int i = 0; i < dimension; i++)
    {
       for (int j = 0; j < dimension; j++)
       {
          if (isMasked(i, j))
          {
             bits.flip(j, i);
          }
       }
    }
 }
開發者ID:Binjaaa,項目名稱:ZXing.Net.Mobile,代碼行數:21,代碼來源:DataMask.cs

示例12: BitMatrixParser

      /// <summary>
      /// <param name="bitMatrix"><see cref="BitMatrix" />to parse</param>
      /// <exception cref="FormatException">if dimension is < 8 or >144 or not 0 mod 2</exception>
      /// </summary>
      internal BitMatrixParser(BitMatrix bitMatrix)
      {
         int dimension = bitMatrix.Height;
         if (dimension < 8 || dimension > 144 || (dimension & 0x01) != 0)
         {
            return;
         }

         version = readVersion(bitMatrix);
         if (version != null)
         {
            mappingBitMatrix = extractDataRegion(bitMatrix);
            readMappingMatrix = new BitMatrix(mappingBitMatrix.Width, mappingBitMatrix.Height);
         }
      }
開發者ID:Binjaaa,項目名稱:ZXing.Net.Mobile,代碼行數:19,代碼來源:BitMatrixParser.cs

示例13: decode

 /// <summary>
 /// <p>Convenience method that can decode a Data Matrix Code represented as a 2D array of booleans.
 /// "true" is taken to mean a black module.</p>
 ///
 /// <param name="image">booleans representing white/black Data Matrix Code modules</param>
 /// <returns>text and bytes encoded within the Data Matrix Code</returns>
 /// <exception cref="FormatException">if the Data Matrix Code cannot be decoded</exception>
 /// <exception cref="ChecksumException">if error correction fails</exception>
 /// </summary>
 public DecoderResult decode(bool[][] image)
 {
    int dimension = image.Length;
    BitMatrix bits = new BitMatrix(dimension);
    for (int i = 0; i < dimension; i++)
    {
       for (int j = 0; j < dimension; j++)
       {
          if (image[i][j])
          {
             bits[j, i] = true;
          }
       }
    }
    return decode(bits);
 }
開發者ID:Redth,項目名稱:ZXing.Net.Mobile,代碼行數:25,代碼來源:Decoder.cs

示例14: Create

        /// <summary>
        /// Initializes a new instance of the <see cref="ZXing.PDF417.Internal.BoundingBox"/> class.
        /// returns null if the corner points don't match up correctly
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="topLeft">The top left.</param>
        /// <param name="bottomLeft">The bottom left.</param>
        /// <param name="topRight">The top right.</param>
        /// <param name="bottomRight">The bottom right.</param>
        /// <returns></returns>
        public static BoundingBox Create(BitMatrix image,
                                         ResultPoint topLeft,
                                         ResultPoint bottomLeft,
                                         ResultPoint topRight,
                                         ResultPoint bottomRight)
        {
            if ((topLeft == null && topRight == null) ||
                (bottomLeft == null && bottomRight == null) ||
                (topLeft != null && bottomLeft == null) ||
                (topRight != null && bottomRight == null))
            {
                return null;
            }

            return new BoundingBox(image, topLeft, bottomLeft, topRight, bottomRight);
        }
開發者ID:hydrayu,項目名稱:imobile-src,代碼行數:26,代碼來源:BoundingBox.cs

示例15: decode

      /// <summary>
      ///   <p>Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.</p>
      /// </summary>
      /// <param name="bits">booleans representing white/black QR Code modules</param>
      /// <param name="hints">The hints.</param>
      /// <returns>
      /// text and bytes encoded within the QR Code
      /// </returns>
      public DecoderResult decode(BitMatrix bits, IDictionary<DecodeHintType, object> hints)
      {
         // Construct a parser and read version, error-correction level
         var parser = BitMatrixParser.createBitMatrixParser(bits);
         if (parser == null)
            return null;

         var result = decode(parser, hints);
         if (result == null)
         {
            // Revert the bit matrix
            parser.remask();

            // Will be attempting a mirrored reading of the version and format info.
            parser.setMirror(true);

            // Preemptively read the version.
            var version = parser.readVersion();
            if (version == null)
               return null;

            // Preemptively read the format information.
            var formatinfo = parser.readFormatInformation();
            if (formatinfo == null)
               return null;

            /*
             * Since we're here, this means we have successfully detected some kind
             * of version and format information when mirrored. This is a good sign,
             * that the QR code may be mirrored, and we should try once more with a
             * mirrored content.
             */
            // Prepare for a mirrored reading.
            parser.mirror();

            result = decode(parser, hints);

            if (result != null)
            {
               // Success! Notify the caller that the code was mirrored.
               result.Other = new QRCodeDecoderMetaData(true);
            }
         }

         return result;
      }
開發者ID:n1rvana,項目名稱:ZXing.NET,代碼行數:54,代碼來源:Decoder.cs


注:本文中的ZXing.Common.BitMatrix類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。