tabs to spaces
This commit is contained in:
parent
2338eeb4c0
commit
cd6f798b85
@ -46,6 +46,11 @@ extern "C" {
|
||||
# include <ImfArray.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STBIMAGE)
|
||||
# define STBI_NO_STDIO
|
||||
# include <stb_image.c>
|
||||
#endif
|
||||
|
||||
#endif // defined(HAVE_FREEIMAGE)
|
||||
|
||||
using namespace nv;
|
||||
@ -94,6 +99,11 @@ namespace nv
|
||||
static bool saveFloatEXR(const char * fileName, const FloatImage * fimage, uint base_component, uint num_components);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_STBIMG)
|
||||
static Image * loadSTB(Stream & s);
|
||||
static Image * loadFloatSTB(Stream & s);
|
||||
#endif
|
||||
|
||||
#endif // defined(HAVE_FREEIMAGE)
|
||||
|
||||
static FloatImage * loadFloatDDS(Stream & s);
|
||||
@ -146,6 +156,11 @@ Image * nv::ImageIO::load(const char * fileName, Stream & s)
|
||||
if (strCaseCmp(extension, ".psd") == 0) {
|
||||
return loadPSD(s);
|
||||
}
|
||||
|
||||
#if defined(HAVE_STBIMAGE)
|
||||
return loadSTB(s);
|
||||
#endif
|
||||
|
||||
#endif // defined(HAVE_FREEIMAGE)
|
||||
|
||||
return NULL;
|
||||
@ -173,7 +188,8 @@ bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, con
|
||||
return savePNG(s, img, tags);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // defined(HAVE_FREEIMAGE)
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -456,8 +472,8 @@ FloatImage * nv::ImageIO::loadFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s)
|
||||
switch (fit)
|
||||
{
|
||||
case FIT_BITMAP:
|
||||
{
|
||||
floatImage->allocate(4, w, h);
|
||||
{
|
||||
FIBITMAP * tmp = FreeImage_ConvertTo32Bits(bitmap);
|
||||
|
||||
uint bitcount = FreeImage_GetBPP(bitmap);
|
||||
@ -485,7 +501,6 @@ FloatImage * nv::ImageIO::loadFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s)
|
||||
|
||||
FreeImage_Unload(tmp);
|
||||
}
|
||||
|
||||
break;
|
||||
case FIT_FLOAT:
|
||||
floatImage->allocate(1, w, h);
|
||||
@ -1757,6 +1772,57 @@ bool nv::ImageIO::saveFloatEXR(const char * fileName, const FloatImage * fimage,
|
||||
|
||||
#endif // defined(HAVE_OPENEXR)
|
||||
|
||||
#if defined(HAVE_STBIMG)
|
||||
|
||||
Image * nv::ImageIO::loadSTB(Stream & s)
|
||||
{
|
||||
// @@ Assumes stream cursor is at the beginning and that image occupies the whole stream.
|
||||
const int len = s.size();
|
||||
uint8 * buffer = new uint8[size];
|
||||
|
||||
s.serialize(buffer, len);
|
||||
|
||||
int w, h, n;
|
||||
uint8 * data = stbi_load_from_memory(buffer, len, &w, &h, &n, 4);
|
||||
|
||||
delete buffer;
|
||||
|
||||
// Copy to image.
|
||||
if (data != NULL) {
|
||||
Image * img = new Image;
|
||||
img->wrap(data, w, h);
|
||||
img->setFormat(n == 4 ? Image::Format_ARGB : Image::Format_RGB);
|
||||
return img;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FloatImage * loadFloatSTB(Stream & s)
|
||||
{
|
||||
// @@ Assumes stream cursor is at the beginning and that image occupies the whole stream.
|
||||
const int len = s.size();
|
||||
uint8 * buffer = new uint8[size];
|
||||
|
||||
s.serialize(buffer, len);
|
||||
|
||||
int w, h, n;
|
||||
float * data = stbi_loadf_from_memory(buffer, len, &w, &h, &n, 0);
|
||||
|
||||
delete buffer;
|
||||
|
||||
// Copy to image.
|
||||
if (data != NULL) {
|
||||
FloatImage * img = new FloatImage;
|
||||
img->wrap(n, w, h);
|
||||
return img;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // defined(HAVE_STBIMG)
|
||||
|
||||
#endif // defined(HAVE_FREEIMAGE)
|
||||
|
||||
FloatImage * nv::ImageIO::loadFloatDDS(Stream & s)
|
||||
|
@ -46,7 +46,7 @@ namespace nv
|
||||
if (channel_count > 4) {
|
||||
return false;
|
||||
}
|
||||
if (depth != 8) {
|
||||
if (depth != 8) { // @@ Add support for 16 bit depths.
|
||||
return false;
|
||||
}
|
||||
if (color_mode != PsdColorMode_RGB) {
|
||||
|
Loading…
Reference in New Issue
Block a user