More tweaks.

pull/216/head
castano 13 years ago
parent ce8647c51d
commit 9ebcff93de

@ -10,7 +10,6 @@ SET(CORE_SRCS
DefsVcWin32.h
FileSystem.h FileSystem.cpp
ForEach.h
HashMap.h
Library.h Library.cpp
Memory.h Memory.cpp
Ptr.h

@ -1,7 +1,7 @@
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
#include "Debug.h"
#include "StrLib.h"
#include "StrLib.h" // StringBuilder
// Extern
#if NV_OS_WIN32 //&& NV_CC_MSVC

@ -6,6 +6,12 @@
/*
HashMap based on Thatcher Ulrich <tu@tulrich.com> container, donated to the Public Domain.
I'd like to do something to reduce the amount of code generated with this template. The type of
U is largely irrelevant to the generated code, except for calls to constructors and destructors,
but the combination of all T and U pairs, generate a large amounts of code.
HashMap is not used in NVTT, so it could be removed from the repository.
*/

@ -64,7 +64,7 @@ namespace nv
static Image * loadFreeImage(FREE_IMAGE_FORMAT fif, Stream & s);
static FloatImage * loadFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s);
static bool saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const ImageMetaData * tags);
static bool saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const char * tags);
static bool saveFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const FloatImage * img, uint base_component, uint num_components);
#else // defined(HAVE_FREEIMAGE)
@ -82,7 +82,7 @@ namespace nv
#if defined(HAVE_PNG)
static Image * loadPNG(Stream & s);
static bool savePNG(Stream & s, const Image * img, const ImageMetaData * tags);
static bool savePNG(Stream & s, const Image * img, const char * tags);
#endif
#if defined(HAVE_JPEG)
@ -166,7 +166,7 @@ Image * nv::ImageIO::load(const char * fileName, Stream & s)
return NULL;
}
bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, const ImageMetaData * tags/*=NULL*/)
bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, const char * tags/*=NULL*/)
{
nvDebugCheck(fileName != NULL);
nvDebugCheck(s.isSaving());
@ -194,7 +194,7 @@ bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, con
return false;
}
bool nv::ImageIO::save(const char * fileName, const Image * img, const ImageMetaData * tags/*=NULL*/)
bool nv::ImageIO::save(const char * fileName, const Image * img, const char * tags/*=NULL*/)
{
nvDebugCheck(fileName != NULL);
nvDebugCheck(img != NULL);
@ -598,7 +598,7 @@ FloatImage * nv::ImageIO::loadFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s)
return floatImage;
}
bool nv::ImageIO::saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const ImageMetaData * tags)
bool nv::ImageIO::saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const char * tags)
{
nvCheck(!s.isError());
@ -1241,7 +1241,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) { }
bool nv::ImageIO::savePNG(Stream & s, const Image * img, const ImageMetaData * tags/*=NULL*/)
bool nv::ImageIO::savePNG(Stream & s, const Image * img, const char * tags/*=NULL*/)
{
nvCheck(!s.isError());
nvCheck(img != NULL);
@ -1291,19 +1291,21 @@ bool nv::ImageIO::savePNG(Stream & s, const Image * img, const ImageMetaData * t
png_set_rows(png_ptr, info_ptr, row_data);
png_text * text = NULL;
if (tags != NULL && tags->tagMap.count() > 0)
if (tags != NULL)
{
text = new png_text[tags->tagMap.count()];
memset(text, 0, tags->tagMap.count() * sizeof(png_text));
int n = 0;
foreach (i, tags->tagMap)
{
text[n].compression = PNG_TEXT_COMPRESSION_NONE;
text[n].key = const_cast<char*> (tags->tagMap[i].key.str());
text[n].text = const_cast<char*> (tags->tagMap[i].value.str());
n++;
int count = 0;
while(tags[2 * count] != NULL) count++;
text = new png_text[count];
memset(text, 0, count * sizeof(png_text);
for (int i = 0; i < count; i++) {
text[i].compression = PNG_TEXT_COMPRESSION_NONE;
text[i].key = tags[2 * i + 0];
text[i].text = tags[2 * i + 1];
}
png_set_text(png_ptr, info_ptr, text, tags->tagMap.count());
png_set_text(png_ptr, info_ptr, text, count);
}
png_write_png(png_ptr, info_ptr,

@ -7,7 +7,6 @@
#include "nvimage.h"
#include "nvcore/StrLib.h"
#include "nvcore/HashMap.h"
namespace nv
@ -18,19 +17,14 @@ namespace nv
namespace ImageIO
{
struct ImageMetaData
{
HashMap<String, String> tagMap;
};
NVIMAGE_API Image * load(const char * fileName);
NVIMAGE_API Image * load(const char * fileName, Stream & s);
NVIMAGE_API FloatImage * loadFloat(const char * fileName);
NVIMAGE_API FloatImage * loadFloat(const char * fileName, Stream & s);
NVIMAGE_API bool save(const char * fileName, const Image * img, const ImageMetaData * tags=NULL);
NVIMAGE_API bool save(const char * fileName, Stream & s, const Image * img, const ImageMetaData * tags=NULL);
NVIMAGE_API bool save(const char * fileName, const Image * img, const char * tags=NULL); // NULL terminated list.
NVIMAGE_API bool save(const char * fileName, Stream & s, const Image * img, const char * tags=NULL);
NVIMAGE_API bool saveFloat(const char * fileName, const FloatImage * fimage, uint baseComponent, uint componentCount);
NVIMAGE_API bool saveFloat(const char * fileName, Stream & s, const FloatImage * fimage, uint baseComponent, uint componentCount);

@ -25,7 +25,7 @@
#ifndef NV_TT_OUTPUTOPTIONS_H
#define NV_TT_OUTPUTOPTIONS_H
#include <nvcore/StrLib.h>
#include <nvcore/StrLib.h> // Path
#include <nvcore/StdStream.h>
#include "nvtt.h"

@ -30,8 +30,8 @@
#include <nvimage/FloatImage.h>
#include <nvimage/DirectDrawSurface.h>
#include <nvcore/Ptr.h>
#include <nvcore/StrLib.h>
#include <nvcore/Ptr.h> // AutoPtr
#include <nvcore/StrLib.h> // Path
#include <nvcore/StdStream.h>
#include <nvcore/FileSystem.h>
#include <nvcore/Timer.h>

Loading…
Cancel
Save