ImageInfo info = new ImageInfo(Width * chunkSize, Height * chunkSize, 8, false);
PngWriter snapWriter = FileHelper.CreatePngWriter(path, info, true);
snapWriter.CompLevel = 5;
- snapWriter.CompressionStrategy = Hjg.Pngcs.Zlib.EDeflateCompressStrategy.Huffman;
+ snapWriter.CompressionStrategy = Hjg.Pngcs.Zlib.EDeflateCompressStrategy.Filtered;
var orderedList =
from ch in cols
orderby g.Key
select g;
// that sorts things in ascending order so we can only create (chunkSize) lines at once
- int row = 0;
+ int row = 0, lastPosY = 0, posY = 0;
foreach (var chunkGroup in orderedList)
{
- var posY = chunkGroup.Key - NorthEdge;
- var inGroup = (await ReadAllInGroup(chunkGroup)).ToArray();
// oh god here we go...
+ posY = chunkGroup.Key - NorthEdge;
+ var delta = posY - lastPosY;
+ lastPosY = posY;
+
+ // if there is more than 1 blank step then the gap needs to be filled.
+ for (int i = 1; i < delta; i++)
+ {
+ byte[] blankLine = new byte[info.BytesPerRow];
+ for (int j = 0; j < chunkSize; j++)
+ snapWriter.WriteRowByte(blankLine, row++);
+ }
+
+ var inGroup = (await ReadAllInGroup(chunkGroup)).ToArray();
+
for (int r = 0; r < chunkSize; r++)
{
var line = new byte[info.BytesPerRow];
}
}
snapWriter.ShouldCloseStream = true;
-
+ try
+ {
+ snapWriter.End();
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("Snapshot exception!");
+ }
Console.WriteLine($"snapshot finished in {t.ElapsedMilliseconds}");
}
Console.WriteLine(e.Message);
return null;
} // do nothing on error
-
}
}
}