Fix PSD file format support. Read stream in big endian format.

This commit is contained in:
castano
2007-07-26 10:39:18 +00:00
parent 2ea2aaaf4d
commit 6cdfaaca58
3 changed files with 12 additions and 2 deletions

View File

@ -25,7 +25,9 @@ SET(IMAGE_SRCS
NormalMap.h NormalMap.h
NormalMap.cpp NormalMap.cpp
NormalMipmap.h NormalMipmap.h
NormalMipmap.cpp) NormalMipmap.cpp
PsdFile.h
TgaFile.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -76,6 +76,9 @@ Image * nv::ImageIO::load(const char * name, Stream & s)
return loadPNG(s); return loadPNG(s);
} }
#endif #endif
if (strCaseCmp(extension, ".psd") == 0) {
return loadPSD(s);
}
// @@ use image plugins? // @@ use image plugins?
return NULL; return NULL;
@ -323,16 +326,20 @@ Image * nv::ImageIO::loadPSD(Stream & s)
nvCheck(!s.isError()); nvCheck(!s.isError());
nvCheck(s.isLoading()); nvCheck(s.isLoading());
s.setByteOrder(Stream::BigEndian);
PsdHeader header; PsdHeader header;
s << header; s << header;
if (!header.isValid()) if (!header.isValid())
{ {
printf("invalid header!\n");
return NULL; return NULL;
} }
if (!header.isSupported()) if (!header.isSupported())
{ {
printf("unsupported file!\n");
return NULL; return NULL;
} }

View File

@ -33,12 +33,13 @@ namespace nv
bool isValid() const bool isValid() const
{ {
return signature == 0x38425053; // '8BPS' return signature == 0x38425053; // 38425053; // '8BPS'
} }
bool isSupported() const bool isSupported() const
{ {
if (version != 1) { if (version != 1) {
printf("*** bad version number %u\n", version);
return false; return false;
} }
if (channel_count > 4) { if (channel_count > 4) {