#define PNG_DEFAULT 0
#define PNG_IGNOREGAMMA 1 // loading: avoid gamma correction
#define PNG_Z_BEST_SPEED 0x0001 // save using ZLib level 1 compression flag (default value is 6)
-#define PNG_Z_DEFAULT_COMPRESSION 0x0006 // save using ZLib level 6 compression flag (default recommended value)
#define PNG_Z_BEST_COMPRESSION 0x0009 // save using ZLib level 9 compression flag (default value is 6)
#define PNG_Z_NO_COMPRESSION 0x0100 // save without ZLib compression
#define PNG_INTERLACED 0x0200 // save using Adam7 interlacing (use | to combine with other save flags)
// ----------------------------------------------------------
-#include "../ZLib/zlib.h"
-#include "../LibPNG/png.h"
+#include <zlib.h>
+#include <png.h>
// ----------------------------------------------------------
tag = FreeImage_CreateTag();
if(!tag) return FALSE;
+#ifdef PNG_iTXt_SUPPORTED
DWORD tag_length = (DWORD) MAX(text_ptr[i].text_length, text_ptr[i].itxt_length);
+#else
+ DWORD tag_length = text_ptr[i].text_length;
+#endif
FreeImage_SetTagLength(tag, tag_length);
FreeImage_SetTagCount(tag, tag_length);
text_metadata.key = (char*)FreeImage_GetTagKey(tag); // keyword, 1-79 character description of "text"
text_metadata.text = (char*)FreeImage_GetTagValue(tag); // comment, may be an empty string (ie "")
text_metadata.text_length = FreeImage_GetTagLength(tag);// length of the text string
+#ifdef PNG_iTXt_SUPPORTED
text_metadata.itxt_length = FreeImage_GetTagLength(tag);// length of the itxt string
text_metadata.lang = 0; // language code, 0-79 characters or a NULL pointer
text_metadata.lang_key = 0; // keyword translated UTF-8 string, 0 or more chars or a NULL pointer
-
+#endif
// set the tag
png_set_text(png_ptr, info_ptr, &text_metadata, 1);
text_metadata.key = (char*)g_png_xmp_keyword; // keyword, 1-79 character description of "text"
text_metadata.text = (char*)FreeImage_GetTagValue(tag); // comment, may be an empty string (ie "")
text_metadata.text_length = FreeImage_GetTagLength(tag);// length of the text string
+#ifdef PNG_iTXt_SUPPORTED
text_metadata.itxt_length = FreeImage_GetTagLength(tag);// length of the itxt string
text_metadata.lang = 0; // language code, 0-79 characters or a NULL pointer
text_metadata.lang_key = 0; // keyword translated UTF-8 string, 0 or more chars or a NULL pointer
-
+#endif
// set the tag
png_set_text(png_ptr, info_ptr, &text_metadata, 1);
bResult &= TRUE;
// Use at your own risk!
// ==========================================================
-#include "../ZLib/zlib.h"
+#include <zlib.h>
#include "FreeImage.h"
#include "Utilities.h"
-#include "../ZLib/zutil.h" /* must be the last header because of error C3163 in VS2008 (_vsnprintf defined in stdio.h) */
/**
Compresses a source buffer into a target buffer, using the ZLib library.
return 0;
case Z_OK: {
// patch header, setup crc and length (stolen from mod_trace_output)
- BYTE *p = target + 8; *p++ = 2; *p = OS_CODE; // xflags, os_code
+ BYTE *p = target + 8; *p++ = 2; *p = 0x03; // xflags, os_code (unix)
crc = crc32(crc, source, source_size);
memcpy(target + 4 + dest_len, &crc, 4);
memcpy(target + 8 + dest_len, &source_size, 4);