Bitmap class decoder supports automatic ungzipping. This is a fix for wrongly configured HTTP servers that send gzipped images even when this is not included in accepted encodings.
#include <algorithm>
#include <cmath>
#include <cstdlib>
+
+#include <stdext/miniz.h>
+
#include <jpeglib.h>
#include <png.h>
#include <webp/decode.h>
@@ -503,11 +506,17 @@ namespace carto {
return loadWEBP(compressedData, dataSize);
} else if (IsNUTI(compressedData, dataSize)) {
return loadNUTI(compressedData, dataSize);
+ } else {
+ std::vector<unsigned char> uncompressedData;
+ if (miniz::inflate_gzip(compressedData, dataSize, uncompressedData)) {
+ Log::Info("Bitmap::loadFromCompressedBytes: Image is gzipped, decompressing");
+ return loadFromCompressedBytes(uncompressedData.data(), uncompressedData.size());
} else {
Log::Error("Bitmap::loadFromCompressedBytes: Unsupported image format");
return false;
}
}
+ }
bool Bitmap::loadFromUncompressedBytes(const unsigned char* pixelData, unsigned int width, unsigned int height, ColorFormat::ColorFormat colorFormat, int bytesPerRow) {
_colorFormat = colorFormat;
