Skip to content

Commit c7c5d08

Browse files
committed
Added function documentation/summaries
1 parent cdabe53 commit c7c5d08

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

QRCoder/ArtQRCode.cs

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,45 @@ public class ArtQRCode : AbstractQRCode, IDisposable
1414
/// </summary>
1515
public ArtQRCode() { }
1616

17+
/// <summary>
18+
/// Creates new ArtQrCode object
19+
/// </summary>
20+
/// <param name="data">QRCodeData generated by the QRCodeGenerator</param>
1721
public ArtQRCode(QRCodeData data) : base(data) { }
1822

23+
/// <summary>
24+
/// Renders an art-style QR code with dots as modules. (With default settings: DarkColor=Black, LightColor=White, Background=Transparent, QuietZone=true)
25+
/// </summary>
26+
/// <param name="pixelsPerModule">Amount of px each dark/light module of the QR code shall take place in the final QR code image</param>
27+
/// <returns>QRCode graphic as bitmap</returns>
1928
public Bitmap GetGraphic(int pixelsPerModule)
2029
{
2130
return this.GetGraphic(pixelsPerModule, Color.Black, Color.White, Color.Transparent);
2231
}
2332

33+
/// <summary>
34+
/// Renders an art-style QR code with dots as modules and a background image (With default settings: DarkColor=Black, LightColor=White, Background=Transparent, QuietZone=true)
35+
/// </summary>
36+
/// <param name="backgroundImage">A bitmap object that will be used as background picture</param>
37+
/// <returns>QRCode graphic as bitmap</returns>
2438
public Bitmap GetGraphic(Bitmap backgroundImage = null)
2539
{
2640
return this.GetGraphic(10, Color.Black, Color.White, Color.Transparent, backgroundImage: backgroundImage);
2741
}
2842

43+
/// <summary>
44+
/// Renders an art-style QR code with dots as modules and various user settings
45+
/// </summary>
46+
/// <param name="pixelsPerModule">Amount of px each dark/light module of the QR code shall take place in the final QR code image</param>
47+
/// <param name="darkColor">Color of the dark modules</param>
48+
/// <param name="lightColor">Color of the light modules</param>
49+
/// <param name="backgroundColor">Color of the background</param>
50+
/// <param name="backgroundImage">A bitmap object that will be used as background picture</param>
51+
/// <param name="pixelSizeFactor">Value between 0.0 to 1.0 that defines how big the module dots are. The bigger the value, the less round the dots will be.</param>
52+
/// <param name="drawQuietZones">If true a white border is drawn around the whole QR Code</param>
53+
/// <param name="quietZoneRenderingStyle">Style of the quiet zones</param>
54+
/// <param name="finderPatternImage">Optional image that should be used instead of the default finder patterns</param>
55+
/// <returns>QRCode graphic as bitmap</returns>
2956
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, Color backgroundColor, Bitmap backgroundImage = null, double pixelSizeFactor = 0.8,
3057
bool drawQuietZones = true, QuietZoneStyle quietZoneRenderingStyle = QuietZoneStyle.Flat, Bitmap finderPatternImage = null)
3158
{
@@ -74,15 +101,13 @@ public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor,
74101
graphics.FillRectangle(solidBrush, rectangleF);
75102
}
76103
}
77-
78104
if (finderPatternImage != null)
79105
{
80106
var finderPatternSize = 7 * pixelsPerModule;
81107
graphics.DrawImage(finderPatternImage, new Rectangle(0, 0, finderPatternSize, finderPatternSize));
82108
graphics.DrawImage(finderPatternImage, new Rectangle(size - finderPatternSize, 0, finderPatternSize, finderPatternSize));
83109
graphics.DrawImage(finderPatternImage, new Rectangle(0, size - finderPatternSize, finderPatternSize, finderPatternSize));
84110
}
85-
86111
graphics.Save();
87112
}
88113
}
@@ -93,9 +118,9 @@ public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor,
93118
/// <summary>
94119
/// If the pixelSize is bigger than the pixelsPerModule or may end up filling the Module making a traditional QR code.
95120
/// </summary>
96-
/// <param name="pixelsPerModule"></param>
97-
/// <param name="pixelSize"></param>
98-
/// <param name="brush"></param>
121+
/// <param name="pixelsPerModule">Pixels used per module rendered</param>
122+
/// <param name="pixelSize">Size of the dots</param>
123+
/// <param name="brush">Color of the pixels</param>
99124
/// <returns></returns>
100125
private Bitmap MakeDotPixel(int pixelsPerModule, int pixelSize, SolidBrush brush)
101126
{
@@ -124,6 +149,13 @@ private Bitmap MakeDotPixel(int pixelsPerModule, int pixelSize, SolidBrush brush
124149
}
125150

126151

152+
/// <summary>
153+
/// Checks if a given module(-position) is part of the quietzone of a QR code
154+
/// </summary>
155+
/// <param name="x">X position</param>
156+
/// <param name="y">Y position</param>
157+
/// <param name="numModules">Total number of modules per row</param>
158+
/// <returns>true, if position is part of quiet zone</returns>
127159
private bool IsPartOfQuietZone(int x, int y, int numModules)
128160
{
129161
return
@@ -134,6 +166,14 @@ private bool IsPartOfQuietZone(int x, int y, int numModules)
134166
}
135167

136168

169+
/// <summary>
170+
/// Checks if a given module(-position) is part of one of the three finder patterns of a QR code
171+
/// </summary>
172+
/// <param name="x">X position</param>
173+
/// <param name="y">Y position</param>
174+
/// <param name="numModules">Total number of modules per row</param>
175+
/// <param name="offset">Offset in modules (usually depending on drawQuietZones parameter)</param>
176+
/// <returns>true, if position is part of any finder pattern</returns>
137177
private bool IsPartOfFinderPattern(int x, int y, int numModules, int offset)
138178
{
139179
var cornerSize = 11 - offset;
@@ -149,10 +189,9 @@ private bool IsPartOfFinderPattern(int x, int y, int numModules, int offset)
149189
/// <summary>
150190
/// Resize to a square bitmap, but maintain the aspect ratio by padding transparently.
151191
/// </summary>
152-
///
153192
/// <param name="image"></param>
154193
/// <param name="newSize"></param>
155-
/// <returns></returns>
194+
/// <returns>Resized image as bitmap</returns>
156195
private Bitmap Resize(Bitmap image, int newSize)
157196
{
158197
if (image == null) return null;
@@ -183,6 +222,9 @@ private Bitmap Resize(Bitmap image, int newSize)
183222
return bm;
184223
}
185224

225+
/// <summary>
226+
/// Defines how the quiet zones shall be rendered.
227+
/// </summary>
186228
public enum QuietZoneStyle
187229
{
188230
Dotted,

0 commit comments

Comments
 (0)