fix up type casting

This commit is contained in:
Dane Springmeyer 2013-07-28 15:45:36 -04:00
parent bbfd111900
commit 889546ab05
2 changed files with 11 additions and 8 deletions

View file

@ -798,7 +798,7 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
// Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time.
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser);
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, size_t len, void *pUser);
// tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally.
mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
@ -2704,7 +2704,7 @@ struct tdefl_output_buffer
mz_bool m_expandable;
};
static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser)
static mz_bool tdefl_output_buffer_putter(const void *pBuf, size_t len, void *pUser)
{
tdefl_output_buffer *p = (tdefl_output_buffer *)pUser;
size_t new_size = p->m_size + len;
@ -4831,4 +4831,4 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
*/

View file

@ -29,8 +29,10 @@
// miniz
#define MINIZ_NO_ARCHIVE_APIS
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include "miniz.c"
extern "C" {
#include "miniz.c"
}
// zlib
#include <zlib.h>
@ -136,12 +138,14 @@ void PNGWriter::finishChunk(size_t start)
{
// Write chunk length at the beginning of the chunk.
size_t payloadLength = buffer->m_size - start - 4 - 4;
writeUInt32BE(buffer->m_pBuf + start, payloadLength);
writeUInt32BE(buffer->m_pBuf + start, static_cast<mz_uint32>(payloadLength));
// 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)
{
@ -361,4 +365,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);
}}