-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removal of
DotNetZip
; explicit zlib deflate
This patch removes the `zlib` source from TiledSharp and relies on intrinsic .NET libraries to decompress gzip and Zlib streams. Since .NET does not have explicit Zlib support, we manually strip the header and footer, and use the `DeflateStream` on the body.
- Loading branch information
1 parent
4be2032
commit b4f9599
Showing
17 changed files
with
15 additions
and
11,366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,12 +188,21 @@ public TmxBase64Data(XElement xData) | |
Data = new MemoryStream(rawData, false); | ||
|
||
var compression = (string)xData.Attribute("compression"); | ||
if (compression == "gzip") | ||
Data = new Ionic.Zlib.GZipStream(Data, | ||
Ionic.Zlib.CompressionMode.Decompress, false); | ||
else if (compression == "zlib") | ||
Data = new Ionic.Zlib.ZlibStream(Data, | ||
Ionic.Zlib.CompressionMode.Decompress, false); | ||
if (compression == "gzip") { | ||
Data = new GZipStream (Data, CompressionMode.Decompress); | ||
} | ||
else if (compression == "zlib") { | ||
// Strip 2-byte header and 4-byte checksum | ||
// TODO: Validate header here | ||
var bodyLength = rawData.Length - 6; | ||
byte[] bodyData = new byte[bodyLength]; | ||
Array.Copy (rawData, 2, bodyData, 0, bodyLength); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marshallward
Author
Owner
|
||
|
||
var bodyStream = new MemoryStream (bodyData, false); | ||
Data = new DeflateStream (bodyStream, CompressionMode.Decompress); | ||
|
||
// TODO: Validate checksum? | ||
} | ||
else if (compression != null) | ||
throw new Exception("TmxBase64Data: Unknown compression."); | ||
} | ||
|
Oops, something went wrong.
Rather than copying the data, you could probably use this MemoryStream constructor that takes an
index
andcount
for specifying the region of the byte array.