Automap (OSS) GIT software repository
Revision | 422068e282950ba824c346d3c91139702d3dc5e5 (tree) |
---|---|
Time | 2020-06-02 22:32:24 |
Author | The Grand Dog <alex.h@me.c...> |
Commiter | The Grand Dog |
fixed snapshot, it now works when there are blank rows of chunks! + added to csproj
@@ -117,4 +117,5 @@ | ||
117 | 117 | </None> |
118 | 118 | </ItemGroup> |
119 | 119 | <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> |
120 | + <Compile Include="Subsystems\Snapshot.cs" /> | |
120 | 121 | </Project> |
\ No newline at end of file |
@@ -44,7 +44,7 @@ namespace Automap | ||
44 | 44 | ImageInfo info = new ImageInfo(Width * chunkSize, Height * chunkSize, 8, false); |
45 | 45 | PngWriter snapWriter = FileHelper.CreatePngWriter(path, info, true); |
46 | 46 | snapWriter.CompLevel = 5; |
47 | - snapWriter.CompressionStrategy = Hjg.Pngcs.Zlib.EDeflateCompressStrategy.Huffman; | |
47 | + snapWriter.CompressionStrategy = Hjg.Pngcs.Zlib.EDeflateCompressStrategy.Filtered; | |
48 | 48 | |
49 | 49 | var orderedList = |
50 | 50 | from ch in cols |
@@ -52,12 +52,24 @@ namespace Automap | ||
52 | 52 | orderby g.Key |
53 | 53 | select g; |
54 | 54 | // 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; | |
56 | 56 | foreach (var chunkGroup in orderedList) |
57 | 57 | { |
58 | - var posY = chunkGroup.Key - NorthEdge; | |
59 | - var inGroup = (await ReadAllInGroup(chunkGroup)).ToArray(); | |
60 | 58 | // 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 | + | |
61 | 73 | for (int r = 0; r < chunkSize; r++) |
62 | 74 | { |
63 | 75 | var line = new byte[info.BytesPerRow]; |
@@ -70,7 +82,14 @@ namespace Automap | ||
70 | 82 | } |
71 | 83 | } |
72 | 84 | snapWriter.ShouldCloseStream = true; |
73 | - | |
85 | + try | |
86 | + { | |
87 | + snapWriter.End(); | |
88 | + } | |
89 | + catch (Exception) | |
90 | + { | |
91 | + Console.WriteLine("Snapshot exception!"); | |
92 | + } | |
74 | 93 | Console.WriteLine($"snapshot finished in {t.ElapsedMilliseconds}"); |
75 | 94 | } |
76 | 95 |
@@ -96,7 +115,6 @@ namespace Automap | ||
96 | 115 | Console.WriteLine(e.Message); |
97 | 116 | return null; |
98 | 117 | } // do nothing on error |
99 | - | |
100 | 118 | } |
101 | 119 | } |
102 | 120 | } |