• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# BitMatrix类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BitMatrix的典型用法代码示例。如果您正苦于以下问题:C# BitMatrix类的具体用法?C# BitMatrix怎么用?C# BitMatrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: XorMatrix

        /// <summary>
        /// Xors the matrix.
        /// </summary>
        /// <param name="first">The first.</param>
        /// <param name="second">The second.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        private static TriStateMatrix XorMatrix(TriStateMatrix first, BitMatrix second)
        {
            int width = first.Width;
            var maskedMatrix = new TriStateMatrix(width);
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < width; y++)
                {
                    MatrixStatus states = first.MStatus(x, y);
                    switch (states)
                    {
                        case MatrixStatus.NoMask:
                            maskedMatrix[x, y, MatrixStatus.NoMask] = first[x, y];
                            break;
                        case MatrixStatus.Data:
                            maskedMatrix[x, y, MatrixStatus.Data] = first[x, y] ^ second[x, y];
                            break;
                        default:
                            throw new ArgumentException("TristateMatrix has None value cell.", "first");
                    }
                }
            }

            return maskedMatrix;
        }
开发者ID:JohnRuddy,项目名称:QRCodes.NET,代码行数:32,代码来源:MatrixExtensions.cs


示例2: testRectangularMatrix

      public void testRectangularMatrix()
      {
         BitMatrix matrix = new BitMatrix(75, 20);
         Assert.AreEqual(75, matrix.Width);
         Assert.AreEqual(20, matrix.Height);
         matrix[10, 0] = true;
         matrix[11, 1] = true;
         matrix[50, 2] = true;
         matrix[51, 3] = true;
         matrix.flip(74, 4);
         matrix.flip(0, 5);

         // Should all be on
         Assert.IsTrue(matrix[10, 0]);
         Assert.IsTrue(matrix[11, 1]);
         Assert.IsTrue(matrix[50, 2]);
         Assert.IsTrue(matrix[51, 3]);
         Assert.IsTrue(matrix[74, 4]);
         Assert.IsTrue(matrix[0, 5]);

         // Flip a couple back off
         matrix.flip(50, 2);
         matrix.flip(51, 3);
         Assert.IsFalse(matrix[50, 2]);
         Assert.IsFalse(matrix[51, 3]);
      }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:26,代码来源:BitMatrixTestCase.cs


示例3: sampleGrid

		public override BitMatrix sampleGrid(BitMatrix image, int dimension, 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, dimension, transform);
		}
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:7,代码来源:DefaultGridSampler.cs


示例4: WriteToStream

        /// <summary>
        /// Renders the matrix in an Encapsuled PostScript format.
        /// </summary>
        /// <param name="matrix">The matrix to be rendered</param>
        /// <param name="stream">Output stream that must be writable</param>
        /// <remarks></remarks>
        public void WriteToStream(BitMatrix matrix, Stream stream)
        {
            using (var writer = new StreamWriter(stream))
            {
                int width = matrix == null ? 21 : matrix.Width;

                DrawingSize drawingSize = m_iSize.GetSize(width);

                OutputHeader(drawingSize, writer);
                OutputBackground(writer);

                if (matrix != null)
                {
                    switch (m_DrawingTechnique)
                    {
                        case EpsModuleDrawingTechnique.Squares:
                            DrawSquares(matrix, writer);
                            break;
                        case EpsModuleDrawingTechnique.Image:
                            DrawImage(matrix, writer);
                            break;
                        default:
                            throw new ArgumentOutOfRangeException("DrawingTechnique");
                    }
                }

                OutputFooter(writer);
            }
        }
开发者ID:JohnRuddy,项目名称:QRCodes.NET,代码行数:35,代码来源:EncapsulatedPostScriptRenderer.cs


示例5: TestPenaltyRule

		private void TestPenaltyRule(BitMatrix input, PenaltyRules penaltyRule, int expected)
		{
			Penalty penalty = new PenaltyFactory().CreateByRule(penaltyRule);
			
			int result = penalty.PenaltyCalculate(input);
			
			AssertIntEquals(expected, result, input, penaltyRule);
		}
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:8,代码来源:PenaltyTestBase.cs


示例6: Embed

 internal static TriStateMatrix Embed(this TriStateMatrix matrix, BitMatrix stencil, IEnumerable<MatrixPoint> locations)
 {
     foreach (MatrixPoint location in locations)
     {
         Embed(matrix, stencil, location);
     }
     return matrix;
 }
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:8,代码来源:TriStateMatrixExtensions.cs


示例7: PenaltyCalculate

		/// <summary>
		/// Calculate penalty value for first rule.
		/// </summary>
        internal override int PenaltyCalculate(BitMatrix matrix)
        {
            MatrixSize size = matrix.Size;
            int penaltyValue = 0;

            penaltyValue = PenaltyCalculation(matrix, true) + PenaltyCalculation(matrix, false);
            return penaltyValue;
        }
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:11,代码来源:Penalty1.cs


示例8: Test_against_DataSet

        public void Test_against_DataSet(TriStateMatrix input, MaskPatternType patternType, BitMatrix expected)
        {
            Pattern pattern = new PatternFactory().CreateByType(patternType);

            BitMatrix result = input.Apply(pattern, ErrorCorrectionLevel.H);

            expected.AssertEquals(result);
        }
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:8,代码来源:MaskPatternTest.cs


示例9: AssertIntEquals

		protected static void AssertIntEquals(int expected, int actual, BitMatrix matrix, PenaltyRules penaltyRule)
        {
			if(expected != actual)
			{
				GenerateFaultyRecord(matrix, penaltyRule, expected, actual);
				Assert.Fail("Penalty scores are different.\nExpected:{0}Actual:{1}.", expected.ToString(), actual.ToString());
				
			}
		}
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:9,代码来源:PenaltyTestBase.cs


示例10: WhiteRectangleDetector

 /// <summary>
 /// Initializes a new instance of the <see cref="WhiteRectangleDetector"/> class.
 /// </summary>
 /// <param name="image">The image.</param>
 /// <exception cref="ArgumentException">if image is too small</exception>
 internal WhiteRectangleDetector(BitMatrix image)
 {
    this.image = image;
    height = image.Height;
    width = image.Width;
    leftInit = (width - INIT_SIZE) >> 1;
    rightInit = (width + INIT_SIZE) >> 1;
    upInit = (height - INIT_SIZE) >> 1;
    downInit = (height + INIT_SIZE) >> 1;
 }
开发者ID:renyh1013,项目名称:dp2,代码行数:15,代码来源:WhiteRectangleDetector.cs


示例11: WhiteRectangleDetector

 /// <summary>
 /// Initializes a new instance of the <see cref="WhiteRectangleDetector"/> class.
 /// </summary>
 /// <param name="image">The image.</param>
 /// <param name="initSize">Size of the init.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 internal WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y)
 {
     this.image = image;
      height = image.Height;
      width = image.Width;
      int halfsize = initSize >> 1;
      leftInit = x - halfsize;
      rightInit = x + halfsize;
      upInit = y - halfsize;
      downInit = y + halfsize;
 }
开发者ID:untitledllc,项目名称:achievements-mobile,代码行数:18,代码来源:WhiteRectangleDetector.cs


示例12: Create

      /// <summary>
      /// Creates a WhiteRectangleDetector instance
      /// </summary>
      /// <param name="image">The image.</param>
      /// <param name="initSize">Size of the init.</param>
      /// <param name="x">The x.</param>
      /// <param name="y">The y.</param>
      /// <returns>
      /// null, if image is too small, otherwise a WhiteRectangleDetector instance
      /// </returns>
      public static WhiteRectangleDetector Create(BitMatrix image, int initSize, int x, int y)
      {
         var instance = new WhiteRectangleDetector(image, initSize, x, y);

         if (instance.upInit < 0 || instance.leftInit < 0 || instance.downInit >= instance.height || instance.rightInit >= instance.width)
         {
            return null;
         }

         return instance;
      }
开发者ID:renyh1013,项目名称:dp2,代码行数:21,代码来源:WhiteRectangleDetector.cs


示例13: DrawBrush

        /// <summary>
        /// Draw QrCode to DrawingBrush
        /// </summary>
        /// <returns>DrawingBrush, Stretch = uniform</returns>
        /// <remarks>LightBrush will not use by this method, DrawingBrush will only contain DarkBrush part.
        /// Use LightBrush to fill background of main uielement for more flexible placement</remarks>
        public DrawingBrush DrawBrush(BitMatrix QrMatrix)
        {
            if (QrMatrix == null)
            {
                return ConstructDrawingBrush(null);
            }

            GeometryDrawing qrCodeDrawing = ConstructQrDrawing(QrMatrix, 0, 0);

            return ConstructDrawingBrush(qrCodeDrawing);
        }
开发者ID:italiazhuang,项目名称:wx_ptest,代码行数:17,代码来源:DrawingBrushRenderer.cs


示例14: PatternCheck

        /// <summary>
        /// Patterns the check.
        /// </summary>
        /// <param name="matrix">The matrix.</param>
        /// <param name="i">The i.</param>
        /// <param name="j">The j.</param>
        /// <param name="isHorizontal">if set to <c>true</c> [is horizontal].</param>
        /// <returns></returns>
        /// <remarks></remarks>
        private int PatternCheck(BitMatrix matrix, int i, int j, bool isHorizontal)
        {
            bool bit;
            for (int num = 3; num >= 1; num--)
            {
                bit = isHorizontal
                          ? matrix[j + num, i]
                          : matrix[i, j + num];
                if (!bit)
                    return 0;
            }
            //Check for left side and right side x ( xoxxxox ).
            if ((j - 1) < 0 || (j + 1) >= matrix.Width)
                return 0;
            bit = isHorizontal
                      ? matrix[j + 5, i]
                      : matrix[i, j + 5];
            if (!bit)
                return 0;
            bit = isHorizontal
                      ? matrix[j - 1, i]
                      : matrix[i, j - 1];
            if (!bit)
                return 0;

            if ((j - 5) >= 0)
            {
                for (int num = -2; num >= -5; num--)
                {
                    bit = isHorizontal
                              ? matrix[j + num, i]
                              : matrix[i, j + num];
                    if (bit)
                        break;
                    if (num == -5)
                        return 40;
                }
            }

            if ((j + 9) < matrix.Width)
            {
                for (int num = 6; num <= 9; num++)
                {
                    bit = isHorizontal
                              ? matrix[j + num, i]
                              : matrix[i, j + num];
                    if (bit)
                        return 0;
                }
                return 40;
            }
            else
                return 0;
        }
开发者ID:JohnRuddy,项目名称:QRCodes.NET,代码行数:63,代码来源:Penalty3.cs


示例15: DrawDarkModule

        /// <summary>
        /// Draw qrCode dark modules at given position. (It will also include quiet zone area. Set it to zero to exclude quiet zone)
        /// </summary>
        /// <exception cref="ArgumentNullException">Bitmatrix, wBitmap should not equal to null</exception>
        /// <exception cref="ArgumentOutOfRangeException">wBitmap's pixel width or height should not equal to zero</exception>
        public void DrawDarkModule(WriteableBitmap wBitmap, BitMatrix matrix, int offsetX, int offsetY)
        {
            if (matrix == null)
                throw new ArgumentNullException("Bitmatrix");

            DrawingSize size = ISize.GetSize(matrix.Width);

            if (wBitmap == null)
                throw new ArgumentNullException("wBitmap");
            else if (wBitmap.PixelHeight == 0 || wBitmap.PixelWidth == 0)
                throw new ArgumentOutOfRangeException("wBitmap", "WriteableBitmap's pixelHeight or PixelWidth are equal to zero");

            int padding = (size.CodeWidth - size.ModuleSize * matrix.Width) / 2;

            int preX = -1;
            int moduleSize = size.ModuleSize;

            if (moduleSize == 0)
                return;

            for (int y = 0; y < matrix.Width; y++)
            {
                for (int x = 0; x < matrix.Width; x++)
                {
                    if (matrix[x, y])
                    {
                        if (preX == -1)
                            preX = x;
                        if (x == matrix.Width - 1)
                        {
                            Int32Rect moduleArea =
                                new Int32Rect(preX * moduleSize + padding + offsetX,
                                    y * moduleSize + padding + offsetY,
                                    (x - preX + 1) * moduleSize,
                                    moduleSize);
                            wBitmap.FillRectangle(moduleArea, DarkColor);
                            preX = -1;
                        }
                    }
                    else if (preX != -1)
                    {
                        Int32Rect moduleArea =
                            new Int32Rect(preX * moduleSize + padding + offsetX,
                                y * moduleSize + padding + offsetY,
                                (x - preX) * moduleSize,
                                moduleSize);
                        wBitmap.FillRectangle(moduleArea, DarkColor);
                        preX = -1;
                    }
                }
            }


        }
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:59,代码来源:WriteableBitmapRenderer.cs


示例16: testSetRegion

 public void testSetRegion()
 {
    BitMatrix matrix = new BitMatrix(5);
    matrix.setRegion(1, 1, 3, 3);
    for (int y = 0; y < 5; y++)
    {
       for (int x = 0; x < 5; x++)
       {
          Assert.AreEqual(y >= 1 && y <= 3 && x >= 1 && x <= 3, matrix[x, y]);
       }
    }
 }
开发者ID:Bogdan-p,项目名称:ZXing.Net,代码行数:12,代码来源:BitMatrixTestCase.cs


示例17: PerformanceTest

		public void PerformanceTest(int rules, ByteMatrix bMatrix, BitMatrix bitMatrix)
		{
			Stopwatch sw = new Stopwatch();
			int timesofTest = 1000;
			
			Penalty penalty = new PenaltyFactory().CreateByRule((PenaltyRules)rules);
			
			
			string[] timeElapsed = new string[2];
			
			sw.Start();
			
			for(int i = 0; i < timesofTest; i++)
			{
				penalty.PenaltyCalculate(bitMatrix);
			}
			
			sw.Stop();
			
			timeElapsed[0] = sw.ElapsedMilliseconds.ToString();
			
			sw.Reset();
			
			sw.Start();
			
			for(int i = 0; i < timesofTest; i++)
			{
				switch(rules)
				{
					case 1:
						MaskUtil.applyMaskPenaltyRule1(bMatrix);
						break;
					case 2:
						MaskUtil.applyMaskPenaltyRule2(bMatrix);
						break;
					case 3:
						MaskUtil.applyMaskPenaltyRule3(bMatrix);
						break;
					case 4:
						MaskUtil.applyMaskPenaltyRule4(bMatrix);
						break;
					default:
						throw new InvalidOperationException(string.Format("Unsupport Rules {0}", rules.ToString()));
				}
			}
			sw.Stop();
			
			timeElapsed[1] = sw.ElapsedMilliseconds.ToString();
			
			
			Assert.Pass("Terminator performance {0} Tests~ QrCode.Net: {1} ZXing: {2}", timesofTest, timeElapsed[0], timeElapsed[1]);
			
		}
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:53,代码来源:PenaltyPTest.cs


示例18: Draw

        /// <summary>
        /// Draw QrCode at given writeable bitmap at offset location
        /// </summary>
        public void Draw(WriteableBitmap wBitmap, BitMatrix matrix, int offsetX, int offsetY)
        {
            DrawingSize size = matrix == null ? ISize.GetSize(21) : ISize.GetSize(matrix.Width);
            if (wBitmap == null)
                wBitmap = new WriteableBitmap(size.CodeWidth + offsetX, size.CodeWidth + offsetY, 96, 96, PixelFormats.Gray8, null);
            else if (wBitmap.PixelHeight == 0 || wBitmap.PixelWidth == 0)
                return; //writeablebitmap contains no pixel.
            this.DrawQuietZone(wBitmap, size.CodeWidth, offsetX, offsetY);
            if (matrix == null)
                return;

            this.DrawDarkModule(wBitmap, matrix, offsetX, offsetY);
        }
开发者ID:fengdc,项目名称:QrCode.Net,代码行数:16,代码来源:WriteableBitmapRenderer.cs


示例19: Create

      /// <summary>
      /// Creates a WhiteRectangleDetector instance
      /// </summary>
      /// <param name="image">The image.</param>
      /// <returns>null, if image is too small, otherwise a WhiteRectangleDetector instance</returns>
      public static WhiteRectangleDetector Create(BitMatrix image)
      {
         if (image == null)
            return null;

         var instance = new WhiteRectangleDetector(image);

         if (instance.upInit < 0 || instance.leftInit < 0 || instance.downInit >= instance.height || instance.rightInit >= instance.width)
         {
            return null;
         }

         return instance;
      }
开发者ID:Woo-Long,项目名称:ZXing.Net.Mobile,代码行数:19,代码来源:WhiteRectangleDetector.cs


示例20: PenaltyCalculation

 /// <summary>
 /// Penalties the calculation.
 /// </summary>
 /// <param name="matrix">The matrix.</param>
 /// <param name="isHorizontal">if set to <c>true</c> [is horizontal].</param>
 /// <returns></returns>
 /// <remarks></remarks>
 private int PenaltyCalculation(BitMatrix matrix, bool isHorizontal)
 {
     int i = 0;
     int j = 1;
     int penalty = 0;
     int width = matrix.Width;
     bool bit;
     while (i < width)
     {
         while (j < width - 5)
         {
             bit = isHorizontal
                       ? matrix[j + 4, i]
                       : matrix[i, j + 4];
             if (!bit)
             {
                 bit = isHorizontal
                           ? matrix[j, i]
                           : matrix[i, j];
                 if (!bit)
                 {
                     penalty += PatternCheck(matrix, i, j, isHorizontal);
                     j += 4;
                 }
                 else
                     j += 4;
             }
             else
             {
                 for (int num = 4; num > 0; num--)
                 {
                     bit = bit = isHorizontal
                                     ? matrix[j + num, i]
                                     : matrix[i, j + num];
                     if (!bit)
                     {
                         j += num;
                         break;
                     }
                     if (num == 1)
                         j += 5;
                 }
             }
         }
         j = 0;
         i++;
     }
     return penalty;
 }
开发者ID:JohnRuddy,项目名称:QRCodes.NET,代码行数:56,代码来源:Penalty3.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BitPack类代码示例发布时间:2022-05-24
下一篇:
C# BitField类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap