• R/O
  • HTTP
  • SSH
  • HTTPS

automap: Commit

Automap (OSS) GIT software repository


Commit MetaInfo

Revision422068e282950ba824c346d3c91139702d3dc5e5 (tree)
Time2020-06-02 22:32:24
AuthorThe Grand Dog <alex.h@me.c...>
CommiterThe Grand Dog

Log Message

fixed snapshot, it now works when there are blank rows of chunks! + added to csproj

Change Summary

Incremental Difference

--- a/Automap/Automap.csproj
+++ b/Automap/Automap.csproj
@@ -117,4 +117,5 @@
117117 </None>
118118 </ItemGroup>
119119 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
120+ <Compile Include="Subsystems\Snapshot.cs" />
120121 </Project>
\ No newline at end of file
--- a/Automap/Subsystems/Snapshot.cs
+++ b/Automap/Subsystems/Snapshot.cs
@@ -44,7 +44,7 @@ namespace Automap
4444 ImageInfo info = new ImageInfo(Width * chunkSize, Height * chunkSize, 8, false);
4545 PngWriter snapWriter = FileHelper.CreatePngWriter(path, info, true);
4646 snapWriter.CompLevel = 5;
47- snapWriter.CompressionStrategy = Hjg.Pngcs.Zlib.EDeflateCompressStrategy.Huffman;
47+ snapWriter.CompressionStrategy = Hjg.Pngcs.Zlib.EDeflateCompressStrategy.Filtered;
4848
4949 var orderedList =
5050 from ch in cols
@@ -52,12 +52,24 @@ namespace Automap
5252 orderby g.Key
5353 select g;
5454 // that sorts things in ascending order so we can only create (chunkSize) lines at once
55- int row = 0;
55+ int row = 0, lastPosY = 0, posY = 0;
5656 foreach (var chunkGroup in orderedList)
5757 {
58- var posY = chunkGroup.Key - NorthEdge;
59- var inGroup = (await ReadAllInGroup(chunkGroup)).ToArray();
6058 // oh god here we go...
59+ posY = chunkGroup.Key - NorthEdge;
60+ var delta = posY - lastPosY;
61+ lastPosY = posY;
62+
63+ // if there is more than 1 blank step then the gap needs to be filled.
64+ for (int i = 1; i < delta; i++)
65+ {
66+ byte[] blankLine = new byte[info.BytesPerRow];
67+ for (int j = 0; j < chunkSize; j++)
68+ snapWriter.WriteRowByte(blankLine, row++);
69+ }
70+
71+ var inGroup = (await ReadAllInGroup(chunkGroup)).ToArray();
72+
6173 for (int r = 0; r < chunkSize; r++)
6274 {
6375 var line = new byte[info.BytesPerRow];
@@ -70,7 +82,14 @@ namespace Automap
7082 }
7183 }
7284 snapWriter.ShouldCloseStream = true;
73-
85+ try
86+ {
87+ snapWriter.End();
88+ }
89+ catch (Exception)
90+ {
91+ Console.WriteLine("Snapshot exception!");
92+ }
7493 Console.WriteLine($"snapshot finished in {t.ElapsedMilliseconds}");
7594 }
7695
@@ -96,7 +115,6 @@ namespace Automap
96115 Console.WriteLine(e.Message);
97116 return null;
98117 } // do nothing on error
99-
100118 }
101119 }
102120 }
Show on old repository browser