+ fix compiling miniz codec in c++11 mode

FIXME: we should compile legacy "C" code with special flags..
This commit is contained in:
artemp 2013-04-19 13:49:16 +01:00
parent 8908a4bd1b
commit c1b25607db
3 changed files with 12 additions and 7 deletions

View file

@ -117,6 +117,7 @@ source = Split(
well_known_srs.cpp
params.cpp
image_filter_types.cpp
miniz_png.cpp
color.cpp
css_color_grammar.cpp
conversions.cpp

View file

@ -2778,7 +2778,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,
*pLen_out = out_buf.m_size-41;
{
mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0,
0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8, (mz_uint8)"\0\0\04\02\06"[num_chans],0,0,0,0,0,0,0,
(mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54};
c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24);
memcpy(out_buf.m_pBuf, pnghdr, 41);

View file

@ -30,8 +30,10 @@
#define MINIZ_NO_ARCHIVE_APIS
#define MINIZ_NO_STDIO
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include "miniz.c"
extern "C" {
#include "miniz.c"
}
// zlib
#include <zlib.h>
@ -142,7 +144,10 @@ void PNGWriter::finishChunk(size_t start)
// Write CRC32 checksum. Don't include the 4-byte length, but /do/ include
// the 4-byte chunk name.
mz_uint32 crc = mz_crc32(MZ_CRC32_INIT, buffer->m_pBuf + start + 4, payloadLength + 4);
mz_uint8 checksum[] = { crc >> 24, crc >> 16, crc >> 8, crc };
mz_uint8 checksum[] = { static_cast<mz_uint8>(crc >> 24),
static_cast<mz_uint8>(crc >> 16),
static_cast<mz_uint8>(crc >> 8),
static_cast<mz_uint8>(crc) };
mz_bool status = tdefl_output_buffer_putter(checksum, 4, buffer);
if (status != MZ_TRUE)
{
@ -362,4 +367,3 @@ template void PNGWriter::writeIDATStripAlpha<image_data_32>(image_data_32 const&
template void PNGWriter::writeIDATStripAlpha<image_view<image_data_32> >(image_view<image_data_32> const& image);
}}