Skip to content

Commit 00d209a

Browse files
committed
comments
1 parent 7c4f863 commit 00d209a

7 files changed

Lines changed: 71 additions & 2 deletions

File tree

Pixie/CommandLineOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace Pixie
55
{
66
/// <summary>
77
/// Options for CommandLine parser
8+
/// each field represent a key in console args
89
/// </summary>
910
class CommandLineOptions
1011
{
@@ -29,6 +30,10 @@ class CommandLineOptions
2930
[Option('h', "height", HelpText = "grid pattern height in symbols", MutuallyExclusiveSet = "Generation")]
3031
public int PatternHeight { get; set; }
3132

33+
/// <summary>
34+
/// Gets help message from assebly attributes
35+
/// </summary>
36+
/// <returns>string representation of help message</returns>
3237
[HelpOption]
3338
public string GetUsage()
3439
{

Pixie/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Pixie
88
internal static class Extensions
99
{
1010
/// <summary>
11-
/// Converts BitArray to byte[]
11+
/// Converts <see cref="BitArray"/> to <see cref="byte[]"/>
1212
/// </summary>
1313
/// <param name="bits"></param>
1414
/// <returns></returns>

Pixie/OutputFileFormatter.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,25 @@ namespace Pixie
77
{
88
static class OutputFileFormatter
99
{
10+
/// <summary>
11+
/// How many elements of array will be displayed in one line
12+
/// </summary>
1013
private const int ElementsPerLine = 10;
1114

15+
/// <summary>
16+
/// Writes formatted output of symbols parser's result
17+
/// </summary>
18+
/// <param name="symbols">byte[] representation of symbols</param>
19+
/// <param name="fileName">path to the file to create</param>
20+
/// <param name="singleArray">shall output be written to single array or one array per symbol</param>
1221
public static void WriteOutput(List<byte[]> symbols, string fileName, bool singleArray = false)
1322
{
1423
try
1524
{
1625
using (var stream = File.Open(fileName, FileMode.Create))
1726
using (var writer = new StreamWriter(stream))
1827
{
28+
// Make header
1929
writer.WriteLine("//");
2030
writer.WriteLine("//");
2131
writer.WriteLine("// Generated with PixelPixie (c) 2016");
@@ -24,6 +34,7 @@ public static void WriteOutput(List<byte[]> symbols, string fileName, bool singl
2434
writer.WriteLine();
2535
writer.WriteLine();
2636

37+
// Write array(s)
2738
if (singleArray)
2839
{
2940
var totalLength = (from s in symbols

Pixie/PatternGenerator.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@
22

33
namespace Pixie
44
{
5+
/// <summary>
6+
/// Generates empty grid pattern bitmap
7+
/// </summary>
58
internal class PatternGenerator
69
{
710
private PixelSettings _settings;
811
private Color _delimeterColor;
912
private static readonly Color BackGround = Color.Gray;
13+
1014
public PatternGenerator(PixelSettings settings)
1115
{
1216
_settings = settings;
1317
_delimeterColor = ColorTranslator.FromHtml(_settings.DelimeterColor);
1418
}
15-
19+
20+
/// <summary>
21+
/// Fills bitmap with solid color and draws a grid on it
22+
/// </summary>
23+
/// <param name="patternWidthCount">width of grid in symbols (cells)</param>
24+
/// <param name="patternHeightCount">height of grid in symbols (cells)</param>
25+
/// <returns>production ready bitmap</returns>
1626
public Bitmap GeneratePattern(int patternWidthCount, int patternHeightCount)
1727
{
1828
var pattentWidth = patternWidthCount*_settings.SymbolWidth +
@@ -28,6 +38,10 @@ public Bitmap GeneratePattern(int patternWidthCount, int patternHeightCount)
2838
return pattern;
2939
}
3040

41+
/// <summary>
42+
/// Fills background with a solid color
43+
/// </summary>
44+
/// <param name="pattern">bitmap to fill</param>
3145
private void FillBackground(Bitmap pattern)
3246
{
3347
for (int j = 0; j < pattern.Height; j++)
@@ -39,6 +53,10 @@ private void FillBackground(Bitmap pattern)
3953
}
4054
}
4155

56+
/// <summary>
57+
/// Draws horizontal lines, wich will devide grid cells
58+
/// </summary>
59+
/// <param name="pattern">bitmap to draw in</param>
4260
private void DrawHorizontalLines(Bitmap pattern)
4361
{
4462
for (int i = 0; i < pattern.Width; i++)
@@ -56,6 +74,10 @@ private void DrawHorizontalLines(Bitmap pattern)
5674
}
5775
}
5876

77+
/// <summary>
78+
/// Draws vertical lines, wich will devide grid cells
79+
/// </summary>
80+
/// <param name="pattern">bitmap to draw in</param>
5981
private void DrawVerticalLines(Bitmap pattern)
6082
{
6183
for (int j = 0; j < pattern.Height; j++)

Pixie/PixelMapper.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public PixelMapper(Bitmap bitmap, PixelSettings settings)
2626
}
2727

2828

29+
/// <summary>
30+
/// map all cells in grid to byte arrays
31+
/// </summary>
32+
/// <returns>list of mapped arrays</returns>
2933
public List<byte[]> MapPixels()
3034
{
3135
var symbols = new List<byte[]>();
@@ -41,6 +45,14 @@ public List<byte[]> MapPixels()
4145
return symbols;
4246
}
4347

48+
/// <summary>
49+
/// processes one symbol (one grid cell)
50+
/// </summary>
51+
/// <param name="symbolXStart">upper left corner of cell X coord</param>
52+
/// <param name="symbolXEnd">bottom right corner of cell X coord</param>
53+
/// <param name="symbolYStart">upper left corner of cell Y coord</param>
54+
/// <param name="symbolYEnd">bottom right corner of cell Y coord</param>
55+
/// <returns>byte representation of symbol</returns>
4456
private byte[] ProcessSymbol(int symbolXStart, int symbolXEnd, int symbolYStart, int symbolYEnd)
4557
{
4658
var bitsCount = (symbolXEnd - symbolXStart)*(symbolYEnd - symbolYStart)*_settings.BitsPerPixel;
@@ -68,6 +80,13 @@ private byte[] ProcessSymbol(int symbolXStart, int symbolXEnd, int symbolYStart,
6880
return bitArray.ToByteArray();
6981
}
7082

83+
/// <summary>
84+
/// Processes one pixel of image and writes corresponding bits in output array
85+
/// </summary>
86+
/// <param name="color">color of pixel</param>
87+
/// <param name="bitsPerPixel">bpp in output array</param>
88+
/// <param name="outputArray">output array</param>
89+
/// <param name="outputArrayPosition">current element in array</param>
7190
private void ProcessPixel(Color color, int bitsPerPixel, BitArray outputArray, ref int outputArrayPosition)
7291
{
7392
if (!ColorMapping.ContainsKey(color))

Pixie/PixelSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Pixie
1212
[DataContract]
1313
internal class PixelSettings
1414
{
15+
#pragma warning disable 0649
1516
[DataMember]
1617
public int BitsPerPixel;
1718

@@ -29,6 +30,7 @@ internal class PixelSettings
2930

3031
[DataMember]
3132
public string DelimeterColor;
33+
#pragma warning restore 0649
3234

3335
[DataMember]
3436
public Dictionary<string, int> ColorMapping;

Pixie/Program.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ static int Main(string[] args)
2222
return (int) ErrorCode.ArgumentsMismatch;
2323
}
2424

25+
/// <summary>
26+
/// parses image and write arrays to output file
27+
/// </summary>
28+
/// <param name="options">parsed command line args</param>
29+
/// <returns>error code</returns>
2530
static int ParseFontImage(CommandLineOptions options)
2631
{
2732
try
@@ -44,6 +49,11 @@ static int ParseFontImage(CommandLineOptions options)
4449
return (int) ErrorCode.NoError;
4550
}
4651

52+
/// <summary>
53+
/// Grid pattern generation and writing to file
54+
/// </summary>
55+
/// <param name="options">parsed command line args</param>
56+
/// <returns>error code</returns>
4757
static int GeneratePattern(CommandLineOptions options)
4858
{
4959
try

0 commit comments

Comments
 (0)