Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
QrMatrix.cs
1using System;
2using System.Text;
3
5{
12 public delegate bool MaskFunction(int x, int y);
13
23 public delegate uint ColorFunction(float CodeX, float CodeY, float DotX, float DotY, DotType Type);
24
28 public class QrMatrix
29 {
30 private static class FinderMarker
31 {
32 private const DotType X = DotType.FinderMarkerForegroundOuter;
33 private const DotType x = DotType.FinderMarkerForegroundInner;
34 private const DotType _ = DotType.FinderMarkerBackground;
35
36 public static readonly DotType[,] Dots = new DotType[,]
37 {
38 { X, X, X, X, X, X, X },
39 { X, _, _, _, _, _, X },
40 { X, _, x, x, x, _, X },
41 { X, _, x, x, x, _, X },
42 { X, _, x, x, x, _, X },
43 { X, _, _, _, _, _, X },
44 { X, X, X, X, X, X, X }
45 };
46 }
47
48 private static class AlignmentMarker
49 {
50 private const DotType X = DotType.AlignmentMarkerForegroundOuter;
51 private const DotType x = DotType.AlignmentMarkerForegroundInner;
52 private const DotType _ = DotType.AlignmentMarkerBackground;
53
54 public static readonly DotType[,] Dots = new DotType[,]
55 {
56 { X, X, X, X, X },
57 { X, _, _, _, X },
58 { X, _, x, _, X },
59 { X, _, _, _, X },
60 { X, X, X, X, X }
61 };
62 }
63
64 private static readonly char[] halfBlocks = new char[] { ' ', '▀', '▄', '█' };
65 private static readonly char[] quarterBlocks = new char[] { ' ', '▘', '▝', '▀', '▖', '▌', '▞', '▛', '▗', '▚', '▐', '▜', '▄', '▙', '▟', '█' };
66
67 private readonly int size;
68 private readonly bool[,] defined;
69 private bool[,] mask;
70 private DotType[,] dots;
71
76 public QrMatrix(int Size)
77 {
78 if (Size < 21)
79 throw new ArgumentException("Invalid size.", nameof(Size));
80
81 this.size = Size;
82 this.defined = this.mask = new bool[Size, Size];
83 this.dots = new DotType[Size, Size];
84 }
85
89 public QrMatrix(DotType[,] Matrix, bool[,] Mask)
90 {
91 int c = Matrix.GetLength(0);
92 if (Matrix.GetLength(1) != c)
93 throw new ArgumentException("Matrix not square.", nameof(Matrix));
94
95 if (c < 21 || c > 177 || ((c - 21) & 3) != 0)
96 throw new ArgumentException("Invalid matrix dimensions.", nameof(Matrix));
97
98 if (Mask.GetLength(0) != c || Mask.GetLength(1) != c)
99 throw new ArgumentException("Mask must be same dimension as matrix.", nameof(Mask));
100
101 this.size = c;
102 this.dots = Matrix;
103 this.mask = Mask;
104 this.defined = (bool[,])Mask.Clone();
105 }
106
110 public int Size => this.size;
111
115 public DotType[,] Dots => this.dots;
116
120 public bool[,] Defined => this.defined;
121
127 public void DrawFinderMarker(int X, int Y)
128 {
129 int x, y;
130
131 for (y = 0; y < 7; y++)
132 {
133 for (x = 0; x < 7; x++)
134 {
135 this.defined[y + Y, x + X] = true;
136 this.dots[y + Y, x + X] = FinderMarker.Dots[y, x];
137 }
138 }
139 }
140
146 public void DrawAlignmentMarker(int X, int Y)
147 {
148 int x, y;
149
150 for (y = 0; y < 5; y++)
151 {
152 for (x = 0; x < 5; x++)
153 {
154 this.defined[y + Y, x + X] = true;
155 this.dots[y + Y, x + X] = AlignmentMarker.Dots[y, x];
156 }
157 }
158 }
159
168 public void HLine(int X1, int X2, int Y, DotType Dot, bool Dotted)
169 {
170 while (X1 <= X2)
171 {
172 if (!this.defined[Y, X1])
173 {
174 this.defined[Y, X1] = true;
175 this.dots[Y, X1] = Dot;
176 }
177
178 X1++;
179
180 if (Dotted)
181 Dot = (DotType)((int)Dot ^ 1);
182 }
183 }
184
193 public void VLine(int X, int Y1, int Y2, DotType Dot, bool Dotted)
194 {
195 while (Y1 <= Y2)
196 {
197 if (!this.defined[Y1, X])
198 {
199 this.defined[Y1, X] = true;
200 this.dots[Y1, X] = Dot;
201 }
202
203 Y1++;
204
205 if (Dotted)
206 Dot = (DotType)((int)Dot ^ 1);
207 }
208 }
209
213 public int NrDefinedDots
214 {
215 get
216 {
217 int Result = 0;
218 int x, y;
219
220 for (y = 0; y < this.size; y++)
221 {
222 for (x = 0; x < this.size; x++)
223 {
224 if (this.defined[y, x])
225 Result++;
226 }
227 }
228
229 return Result;
230 }
231 }
232
236 public int NrUndefined => this.size * this.size - this.NrDefinedDots;
237
243 public bool EncodeDataBits(byte[] Data)
244 {
245 int i = 0;
246 int c = Data.Length;
247 int State = 0;
248 int x = this.size - 1;
249 int y = this.size - 1;
250 int j;
251 byte b;
252
253 while (i < c)
254 {
255 b = Data[i++];
256
257 for (j = 0; j < 8; j++)
258 {
259 if (x < 0)
260 return false;
261
262 if (this.defined[y, x])
263 j--;
264 else
265 {
266 this.defined[y, x] = true;
267 this.dots[y, x] = (b & 0x80) != 0 ? DotType.CodeForeground : DotType.CodeBackground;
268 b <<= 1;
269 }
270
271 switch (State)
272 {
273 case 0:
274 x--;
275 State++;
276 break;
277
278 case 1:
279 if (y == 0)
280 {
281 x--;
282 if (x == 6)
283 x--;
284 State++;
285 }
286 else
287 {
288 y--;
289 x++;
290 State--;
291 }
292 break;
293
294 case 2:
295 x--;
296 State++;
297 break;
298
299 case 3:
300 if (y == this.size - 1)
301 {
302 x--;
303 State = 0;
304 }
305 else
306 {
307 y++;
308 x++;
309 State--;
310 }
311 break;
312 }
313 }
314 }
315
316 return true;
317 }
318
326 public string ToFullBlockText()
327 {
328 StringBuilder sb = new StringBuilder();
329
330 string s = new string(' ', 16 + (this.size << 1));
331 int x, y;
332
333 for (y = 0; y < 4; y++)
334 sb.AppendLine(s);
335
336 for (y = 0; y < this.size; y++)
337 {
338 sb.Append(" ");
339
340 for (x = 0; x < this.size; x++)
341 {
342 if (((int)this.dots[y, x] & 1) != 0)
343 sb.Append("██");
344 else
345 sb.Append(" ");
346 }
347
348 sb.AppendLine(" ");
349 }
350
351 for (y = 0; y < 4; y++)
352 sb.AppendLine(s);
353
354 return sb.ToString();
355 }
356
364 public string ToHalfBlockText()
365 {
366 StringBuilder sb = new StringBuilder();
367
368 string s = new string(' ', 8 + this.size);
369 int x, y, y2;
370 int i;
371
372 for (y = 0; y < 4; y++)
373 sb.AppendLine(s);
374
375 for (y = 0; y < this.size; y += 2)
376 {
377 y2 = y + 1;
378
379 sb.Append(" ");
380
381 for (x = 0; x < this.size; x++)
382 {
383 i = (int)this.dots[y, x] & 1;
384
385 if (y2 < this.size && ((int)this.dots[y2, x] & 1) != 0)
386 i |= 2;
387
388 sb.Append(halfBlocks[i]);
389 }
390
391 sb.AppendLine(" ");
392 }
393
394 for (y = 0; y < 4; y++)
395 sb.AppendLine(s);
396
397 return sb.ToString();
398 }
399
407 public string ToQuarterBlockText()
408 {
409 StringBuilder sb = new StringBuilder();
410
411 string s = new string(' ', 4 + (this.size + 1) >> 1);
412 int x, y, x2, y2;
413 int i;
414
415 sb.AppendLine(s);
416 sb.AppendLine(s);
417
418 for (y = 0; y < this.size; y += 2)
419 {
420 y2 = y + 1;
421
422 sb.Append(" ");
423
424 for (x = 0; x < this.size; x++)
425 {
426 x2 = x + 1;
427
428 i = (int)this.dots[y, x] & 1;
429
430 if (x2 < this.size && ((int)this.dots[y, x2] & 1) != 0)
431 i |= 2;
432
433 if (y2 < this.size && ((int)this.dots[y2, x] & 1) != 0)
434 i |= 4;
435
436 if (x2 < this.size && y2 < this.size && ((int)this.dots[y2, x2] & 1) != 0)
437 i |= 8;
438
439 sb.Append(quarterBlocks[i]);
440 }
441
442 sb.AppendLine(" ");
443 }
444
445 sb.AppendLine(s);
446 sb.AppendLine(s);
447
448 return sb.ToString();
449 }
450
456 {
457 int x, y, c;
458 int Result = 0;
459 bool? Prev;
460 bool b;
461
462 for (y = 0; y < this.size; y++)
463 {
464 Prev = null;
465 c = 0;
466
467 for (x = 0; x < this.size; x++)
468 {
469 if (Prev.HasValue)
470 {
471 if (Prev == (b = ((int)this.dots[y, x] & 1) != 0))
472 {
473 c++;
474 if (c == 5)
475 Result += 3;
476 else if (c > 5)
477 Result++;
478 }
479 else
480 {
481 c = 1;
482 Prev = b;
483 }
484 }
485 else
486 {
487 Prev = ((int)this.dots[y, x] & 1) != 0;
488 c = 1;
489 }
490 }
491 }
492
493 return Result;
494 }
495
501 {
502 int x, y, c;
503 int Result = 0;
504 bool? Prev;
505 bool b;
506
507 for (x = 0; x < this.size; x++)
508 {
509 Prev = null;
510 c = 0;
511
512 for (y = 0; y < this.size; y++)
513 {
514 if (Prev.HasValue)
515 {
516 if (Prev == (b = ((int)this.dots[y, x] & 1) != 0))
517 {
518 c++;
519 if (c == 5)
520 Result += 3;
521 else if (c > 5)
522 Result++;
523 }
524 else
525 c = 1;
526
527 Prev = b;
528 }
529 else
530 {
531 Prev = ((int)this.dots[y, x] & 1) != 0;
532 c = 1;
533 }
534 }
535 }
536
537 return Result;
538 }
539
544 public int PenaltyBlocks()
545 {
546 int x, y, c = this.size - 1;
547 int Result = 0;
548 int b;
549
550 for (y = 0; y < c; y++)
551 {
552 for (x = 0; x < c; x++)
553 {
554 b = (int)this.dots[y, x] & 1;
555
556 if (((int)this.dots[y + 1, x] & 1) == b &&
557 ((int)this.dots[y, x + 1] & 1) == b &&
558 ((int)this.dots[y + 1, x + 1] & 1) == b)
559 {
560 Result += 3;
561 }
562 }
563 }
564
565 return Result;
566 }
567
573 {
574 int x, y, i;
575 int Result = 0;
576 bool b;
577
578 for (y = 0; y < this.size; y++)
579 {
580 i = 0;
581 for (x = 0; x < this.size; x++)
582 {
583 b = ((int)this.dots[y, x] & 1) != 0;
584 switch (i)
585 {
586 case 0:
587 case 1:
588 case 2:
589 case 3:
590 case 5:
591 case 9:
592 if (!b)
593 i++;
594 else
595 i = 0;
596 break;
597
598 case 4:
599 if (b)
600 i++;
601 break;
602
603 case 6:
604 case 7:
605 case 8:
606 if (b)
607 i++;
608 else
609 i = 0;
610 break;
611
612 case 10:
613 if (b)
614 Result += 40;
615
616 i = 0;
617 break;
618 }
619 }
620 }
621
622 return Result;
623 }
624
630 {
631 int x, y, i;
632 int Result = 0;
633 bool b;
634
635 for (x = 0; x < this.size; x++)
636 {
637 i = 0;
638 for (y = 0; y < this.size; y++)
639 {
640 b = ((int)this.dots[y, x] & 1) != 0;
641 switch (i)
642 {
643 case 0:
644 case 1:
645 case 2:
646 case 3:
647 case 5:
648 case 9:
649 if (!b)
650 i++;
651 else
652 i = 0;
653 break;
654
655 case 4:
656 if (b)
657 i++;
658 break;
659
660 case 6:
661 case 7:
662 case 8:
663 if (b)
664 i++;
665 else
666 i = 0;
667 break;
668
669 case 10:
670 if (b)
671 Result += 40;
672
673 i = 0;
674 break;
675 }
676 }
677 }
678
679 return Result;
680 }
681
687 public int PenaltyBalance()
688 {
689 int x, y;
690 int NrDark = 0;
691 int NrLight = 0;
692
693 for (y = 0; y < this.size; y++)
694 {
695 for (x = 0; x < this.size; x++)
696 {
697 if (((int)this.dots[y, x] & 1) != 0)
698 NrDark++;
699 else
700 NrLight++;
701 }
702 }
703
704 int PercentDark = (100 * NrDark) / (NrDark + NrLight);
705 int Prev5 = (PercentDark / 5) * 5;
706 int Next5 = Prev5 += 5;
707
708 Prev5 = Math.Abs(Prev5 - 50) / 5;
709 Next5 = Math.Abs(Next5 - 50) / 5;
710
711 return Math.Min(Prev5, Next5) * 10;
712 }
713
718 public int Penalty()
719 {
720 return this.Penalty(null);
721 }
722
728 public int Penalty(MaskFunction Mask)
729 {
730 DotType[,] Bak = this.dots;
731
732 if (!(Mask is null))
733 this.ApplyMask(Mask);
734
735 int Result =
737 this.PenaltyVerticalBands() +
738 this.PenaltyBlocks() +
741 this.PenaltyBalance();
742
743 this.dots = Bak;
744
745 return Result;
746 }
747
754 public static bool Mask0(int x, int y) => ((x + y) & 1) == 0;
755
762 public static bool Mask1(int _, int y) => (y & 1) == 0;
763
770 public static bool Mask2(int x, int _) => (x % 3) == 0;
771
778 public static bool Mask3(int x, int y) => ((x + y) % 3) == 0;
779
786 public static bool Mask4(int x, int y) => (((x / 3) + (y / 2)) & 1) == 0;
787
794 public static bool Mask5(int x, int y) => ((x * y) & 1) + ((x * y) % 3) == 0;
795
802 public static bool Mask6(int x, int y) => ((((x * y) & 1) + ((x * y) % 3)) & 1) == 0;
803
810 public static bool Mask7(int x, int y) => ((((x + y) & 1) + ((x * y) % 3)) & 1) == 0;
811
815 public void SaveMask()
816 {
817 this.mask = (bool[,])this.defined.Clone();
818 }
819
824 public void ApplyMask(MaskFunction Mask)
825 {
826 int x, y;
827
828 this.dots = (DotType[,])this.dots.Clone();
829
830 for (y = 0; y < this.size; y++)
831 {
832 for (x = 0; x < this.size; x++)
833 {
834 if (!this.mask[y, x] && Mask(x, y))
835 this.dots[y, x] = (DotType)((int)this.dots[y, x] ^ 1);
836 }
837 }
838 }
839
849 public void WriteBits(uint Bits, int X, int Y, int Dx, int Dy, int NrBits)
850 {
851 while (NrBits > 0)
852 {
853 this.defined[Y, X] = true;
854 this.dots[Y, X] = (Bits & 0x80000000) != 0 ? DotType.CodeForeground : DotType.CodeBackground;
855 Bits <<= 1;
856 NrBits--;
857 X += Dx;
858 Y += Dy;
859 }
860 }
861
867 public byte[] ToRGBA()
868 {
869 return this.ToRGBA(this.size + 8, this.size + 8);
870 }
871
879 public byte[] ToRGBA(int Width, int Height)
880 {
881 byte[] Result = new byte[Width * Height * 4];
882 int SourceSize = this.size + 8;
883 int HalfSourceSize = SourceSize >> 1;
884 int HalfWidth = Width >> 1;
885 int HalfHeight = Height >> 1;
886 int Left = (4 * Width + HalfSourceSize) / SourceSize;
887 int Top = (4 * Height + HalfSourceSize) / SourceSize;
888 int dx = ((SourceSize << 16) + HalfWidth) / Width;
889 int dy = ((SourceSize << 16) + HalfHeight) / Height;
890 int i = 0;
891 int imgX, imgY;
892 int srcX, srcY;
893 int x, y;
894
895 for (imgY = srcY = 0; imgY < Height; imgY++)
896 {
897 y = srcY >> 16;
898
899 if (imgY < Top || y >= this.size)
900 {
901 for (imgX = 0; imgX < Width; imgX++)
902 {
903 Result[i++] = 0xff;
904 Result[i++] = 0xff;
905 Result[i++] = 0xff;
906 Result[i++] = 0xff;
907 }
908
909 continue;
910 }
911
912 for (imgX = 0; imgX < Left; imgX++)
913 {
914 Result[i++] = 0xff;
915 Result[i++] = 0xff;
916 Result[i++] = 0xff;
917 Result[i++] = 0xff;
918 }
919
920 for (srcX = 0; imgX < Width; imgX++)
921 {
922 x = srcX >> 16;
923 if (x >= this.size)
924 break;
925
926 if (((int)this.dots[y, x] & 1) != 0)
927 {
928 Result[i++] = 0x00;
929 Result[i++] = 0x00;
930 Result[i++] = 0x00;
931 }
932 else
933 {
934 Result[i++] = 0xff;
935 Result[i++] = 0xff;
936 Result[i++] = 0xff;
937 }
938
939 Result[i++] = 0xff;
940 srcX += dx;
941 }
942
943 for (; imgX < Width; imgX++)
944 {
945 Result[i++] = 0xff;
946 Result[i++] = 0xff;
947 Result[i++] = 0xff;
948 Result[i++] = 0xff;
949 }
950
951 srcY += dy;
952 }
953
954 return Result;
955 }
956
964 public byte[] ToRGBA(ColorFunction Color, bool AntiAlias)
965 {
966 return this.ToRGBA(this.size + 8, this.size + 8, Color, AntiAlias);
967 }
968
978 public byte[] ToRGBA(int Width, int Height, ColorFunction Color, bool AntiAlias)
979 {
980 int RawLine = 4 * (Width + 1);
981 byte[] Raw = new byte[AntiAlias ? (Width + 1) * (Height + 1) * 4 : Width * Height * 4];
982 byte[] Result = AntiAlias ? new byte[Width * Height * 4] : Raw;
983 int SourceMargin = 4;
984 float SourceSize = this.size + (2 * SourceMargin);
985 float dx = SourceSize / Width;
986 float dy = SourceSize / Height;
987 float x0 = -SourceMargin - 0.5f;
988 float y0 = -SourceMargin - 0.5f;
989 int i, j, k;
990 int imgX, imgY;
991 int srcX, srcY;
992 float x, y, scale;
993 uint cl;
994 int v1, v2, v3, v4;
995 float px1, px2;
996 float py1, py2;
997 float f1, f2;
998 DotType Dot;
999 bool yOutside;
1000
1001 scale = 1.0f / this.size;
1002
1003 for (imgY = i = 0, y = y0; imgY < Height; imgY++, y += dy)
1004 {
1005 srcY = (int)Math.Floor(y);
1006 yOutside = srcY < 0 || srcY >= this.size;
1007
1008 for (imgX = 0, x = x0; imgX < Width; imgX++, x += dx)
1009 {
1010 srcX = (int)Math.Floor(x);
1011
1012 if (yOutside || srcX < 0 || srcX >= this.size)
1013 Dot = DotType.CodeBackground;
1014 else
1015 Dot = this.dots[srcY, srcX];
1016
1017 cl = Color(x * scale, y * scale, x - srcX, y - srcY, Dot);
1018
1019 Raw[i++] = (byte)cl;
1020 cl >>= 8;
1021 Raw[i++] = (byte)cl;
1022 cl >>= 8;
1023 Raw[i++] = (byte)cl;
1024 cl >>= 8;
1025 Raw[i++] = (byte)cl;
1026 }
1027
1028 if (AntiAlias)
1029 {
1030 for (j = 4; j > 0; j--, i++)
1031 Raw[i] = Raw[i - 4];
1032 }
1033 }
1034
1035 if (AntiAlias)
1036 {
1037 for (j = RawLine; j > 0; j--, i++)
1038 Raw[i] = Raw[i - RawLine];
1039
1040 for (imgY = i = k = 0, y = y0; imgY < Height; imgY++, y += dy)
1041 {
1042 srcY = (int)Math.Floor(y);
1043 py1 = y - srcY;
1044 py2 = 1 - py1;
1045
1046 for (imgX = 0, x = x0; imgX < Width; imgX++, x += dx)
1047 {
1048 srcX = (int)Math.Floor(x);
1049 px1 = x - srcX;
1050 px2 = 1 - px1;
1051
1052 for (j = 4; j > 0; j--, i++)
1053 {
1054 v1 = Raw[i];
1055 v2 = Raw[i + 4];
1056 v3 = Raw[i + RawLine];
1057 v4 = Raw[i + RawLine + 4];
1058
1059 f1 = px2 * v1 + px1 * v2;
1060 f2 = px2 * v3 + px1 * v4;
1061
1062 v1 = (int)(f1 * py1 + f2 * py2 + 0.5f);
1063 Result[k++] = (byte)(v1 < 0 ? 0 : v1 > 255 ? 255 : v1);
1064 }
1065 }
1066
1067 i += 4;
1068 }
1069 }
1070
1071 return Result;
1072 }
1073
1074 }
1075}
Class used to compute a QR code matrix.
Definition: QrMatrix.cs:29
bool EncodeDataBits(byte[] Data)
Encodes data bits in free positions in the matrix.
Definition: QrMatrix.cs:243
int NrDefinedDots
Number of defined dots in the matrix.
Definition: QrMatrix.cs:214
void WriteBits(uint Bits, int X, int Y, int Dx, int Dy, int NrBits)
Writes bits to the matrix.
Definition: QrMatrix.cs:849
void ApplyMask(MaskFunction Mask)
Applies a mask on the matrix.
Definition: QrMatrix.cs:824
QrMatrix(int Size)
Class used to compute a QR code matrix.
Definition: QrMatrix.cs:76
int PenaltyBalance()
Calculates a penalty score based on the balance between dark and light dots.
Definition: QrMatrix.cs:687
int PenaltyHorizontalBands()
Calculates a penalty score based on horizontal bands of dots of the same color.
Definition: QrMatrix.cs:455
void DrawAlignmentMarker(int X, int Y)
Draws a Alignment marker pattern in the matrix.
Definition: QrMatrix.cs:146
static bool Mask7(int x, int y)
Mask function 7
int PenaltyBlocks()
Calculates a penalty score based on same colored blocks.
Definition: QrMatrix.cs:544
int PenaltyHorizontalFinderPattern()
Calculates a penalty score based on horizontal finder patterns found.
Definition: QrMatrix.cs:572
static bool Mask4(int x, int y)
Mask function 4
static bool Mask0(int x, int y)
Mask function 0
static bool Mask6(int x, int y)
Mask function 6
string ToFullBlockText()
Generates a text string representing the QR code using full block characters and spaces....
Definition: QrMatrix.cs:326
int NrUndefined
Number of undefined dots in the matrix.
Definition: QrMatrix.cs:236
int Penalty()
Calculates the total penalty score of the matrix.
Definition: QrMatrix.cs:718
int Penalty(MaskFunction Mask)
Calculates the total penalty score of the matrix.
Definition: QrMatrix.cs:728
DotType[,] Dots
Encoded dots.
Definition: QrMatrix.cs:115
QrMatrix(DotType[,] Matrix, bool[,] Mask)
Class used to compute a QR code matrix.
Definition: QrMatrix.cs:89
void HLine(int X1, int X2, int Y, DotType Dot, bool Dotted)
Draws a horizontal line in the matrix.
Definition: QrMatrix.cs:168
static bool Mask3(int x, int y)
Mask function 3
byte[] ToRGBA(int Width, int Height)
Converts the matrix to pixels, each pixel represented by 4 bytes in the order Red,...
Definition: QrMatrix.cs:879
string ToHalfBlockText()
Generates a text string representing the QR code using half block characters and spaces....
Definition: QrMatrix.cs:364
int Size
Size of the matrix (along each side).
Definition: QrMatrix.cs:110
void VLine(int X, int Y1, int Y2, DotType Dot, bool Dotted)
Draws a horizontal line in the matrix.
Definition: QrMatrix.cs:193
void DrawFinderMarker(int X, int Y)
Draws a Finder marker pattern in the matrix.
Definition: QrMatrix.cs:127
byte[] ToRGBA()
Converts the matrix to pixels, each pixel represented by 4 bytes in the order Red,...
Definition: QrMatrix.cs:867
int PenaltyVerticalFinderPattern()
Calculates a penalty score based on vertical finder patterns found.
Definition: QrMatrix.cs:629
bool[,] Defined
What parts of the mask has been defined.
Definition: QrMatrix.cs:120
static bool Mask2(int x, int _)
Mask function 2
static bool Mask5(int x, int y)
Mask function 5
void SaveMask()
Saves the currently defined dots as a mask.
Definition: QrMatrix.cs:815
int PenaltyVerticalBands()
Calculates a penalty score based on horizontal bands of dots of the same color.
Definition: QrMatrix.cs:500
static bool Mask1(int _, int y)
Mask function 1
byte[] ToRGBA(ColorFunction Color, bool AntiAlias)
Converts the matrix to pixels, each pixel represented by 4 bytes in the order Red,...
Definition: QrMatrix.cs:964
byte[] ToRGBA(int Width, int Height, ColorFunction Color, bool AntiAlias)
Converts the matrix to pixels, each pixel represented by 4 bytes in the order Red,...
Definition: QrMatrix.cs:978
string ToQuarterBlockText()
Generates a text string representing the QR code using quarter block characters and spaces....
Definition: QrMatrix.cs:407
delegate uint ColorFunction(float CodeX, float CodeY, float DotX, float DotY, DotType Type)
Delegate for QR-code color functions
delegate bool MaskFunction(int x, int y)
Delegate for mask functions
DotType
Type of dot in code.
Definition: Enumerations.cs:64