Add support for comments.
This commit is contained in:
@ -1004,7 +1004,7 @@ static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t leng
|
|||||||
|
|
||||||
static void user_write_flush(png_structp png_ptr) { }
|
static void user_write_flush(png_structp png_ptr) { }
|
||||||
|
|
||||||
bool nv::ImageIO::savePNG(Stream & s, const Image * img)
|
bool nv::ImageIO::savePNG(Stream & s, const Image * img, const PngCommentsMap & comments)
|
||||||
{
|
{
|
||||||
nvCheck(!s.isError());
|
nvCheck(!s.isError());
|
||||||
nvCheck(img != NULL);
|
nvCheck(img != NULL);
|
||||||
@ -1052,21 +1052,21 @@ bool nv::ImageIO::savePNG(Stream & s, const Image * img)
|
|||||||
}
|
}
|
||||||
png_set_rows(png_ptr, info_ptr, row_data);
|
png_set_rows(png_ptr, info_ptr, row_data);
|
||||||
|
|
||||||
png_text* text = 0;
|
png_text * text = NULL;
|
||||||
/*if (comments.size() > 0)
|
if (comments.size() > 0)
|
||||||
{
|
{
|
||||||
text = new png_text[comments.size()];
|
text = new png_text[comments.size()];
|
||||||
memset(text, 0, comments.size() * sizeof(png_text));
|
memset(text, 0, comments.size() * sizeof(png_text));
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (PngCommentsType::const_iterator comment = comments.begin(); comment != comments.end(); comment++)
|
foreach (i, comments)
|
||||||
{
|
{
|
||||||
text[n].compression = PNG_TEXT_COMPRESSION_NONE;
|
text[n].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||||
text[n].key = const_cast<char*> (comment->first.c_str());
|
text[n].key = const_cast<char*> (comments[i].key.str());
|
||||||
text[n].text = const_cast<char*> (comment->second.c_str());
|
text[n].text = const_cast<char*> (comments[i].value.str());
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
png_set_text(png_ptr, info_ptr, text, comments.size());
|
png_set_text(png_ptr, info_ptr, text, comments.size());
|
||||||
}*/
|
}
|
||||||
|
|
||||||
png_write_png(png_ptr, info_ptr,
|
png_write_png(png_ptr, info_ptr,
|
||||||
// component order is BGR(A)
|
// component order is BGR(A)
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
#include <nvimage/nvimage.h>
|
#include <nvimage/nvimage.h>
|
||||||
|
|
||||||
#include <string>
|
#include <nvcore/StrLib.h>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace nv
|
namespace nv
|
||||||
{
|
{
|
||||||
@ -33,7 +33,8 @@ namespace nv
|
|||||||
|
|
||||||
#if defined(HAVE_PNG)
|
#if defined(HAVE_PNG)
|
||||||
NVIMAGE_API Image * loadPNG(Stream & s);
|
NVIMAGE_API Image * loadPNG(Stream & s);
|
||||||
NVIMAGE_API bool savePNG(Stream & s, const Image * img);
|
typedef HashMap<String, String> PngCommentsMap;
|
||||||
|
NVIMAGE_API bool savePNG(Stream & s, const Image * img, const PngCommentsMap & comments = PngCommentsMap());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_JPEG)
|
#if defined(HAVE_JPEG)
|
||||||
|
Reference in New Issue
Block a user