Permalink
Browse files

Fix Proto2ES Zlib Compression (#1269)

Pass the correct dataSize to EnigmaStruct images which is the size of the image data compressed.
  • Loading branch information...
RobertBColton committed Jun 7, 2018
1 parent 53d9a2f commit 4c20a1915a5129493fa946c0088dab38b3dc7c7c
Showing with 4 additions and 2 deletions.
  1. +4 −2 CommandLine/emake/Proto2ES.cpp
@@ -237,13 +237,15 @@ std::string Actions2Code(const ::google::protobuf::RepeatedPtrField< buffers::re

#include <zlib.h>

unsigned char* zlib_compress(unsigned char* inbuffer,int actualsize)
unsigned char* zlib_compress(unsigned char* inbuffer,int &actualsize)
{
uLongf outsize=(int)(actualsize*1.1)+12;
Bytef* outbytef=new Bytef[outsize];

compress(outbytef,&outsize,(Bytef*)inbuffer,actualsize);

actualsize = outsize;

return (unsigned char*)outbytef;
}

@@ -281,8 +283,8 @@ Image AddImage(const std::string fname) {
free(image);
i.width = pngwidth;
i.height = pngheight;
i.data = reinterpret_cast<char*>(zlib_compress(bitmap, bitmap_size));
i.dataSize = bitmap_size;
i.data = reinterpret_cast<char*>(zlib_compress(bitmap, i.dataSize));

return i;
}

0 comments on commit 4c20a19

Please sign in to comment.