16-bit tiff and png saving broken on big endian, Issue 2675

This commit is contained in:
Ingo
2015-02-22 23:36:28 +01:00
parent 4e8a326645
commit b724b616f2
3 changed files with 15 additions and 4 deletions

View File

@@ -44,7 +44,7 @@ Interpreter stdInterpreter;
#define TAG_SUBFILETYPE 0x00fe
TagDirectory::TagDirectory ()
: attribs(ifdAttribs), order(INTEL), parent(NULL) {}
: attribs(ifdAttribs), order(HOSTORDER), parent(NULL) {}
TagDirectory::TagDirectory (TagDirectory* p, const TagAttrib* ta, ByteOrder border)
: attribs(ta), order(border), parent(p) {}
@@ -2244,7 +2244,7 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro
// write tiff header
int offs = 0;
ByteOrder order = INTEL;
ByteOrder order = HOSTORDER;
if (root)
order = root->getOrder ();
sset2 ((unsigned short)order, buffer+offs, order); offs += 2;
@@ -2255,7 +2255,7 @@ int ExifManager::createTIFFHeader (const TagDirectory* root, const rtengine::pro
if (root)
cl = (const_cast<TagDirectory*>(root))->clone (NULL);
else
cl = new TagDirectory (NULL, ifdAttribs, INTEL);
cl = new TagDirectory (NULL, ifdAttribs, HOSTORDER);
// add tiff strip data
int rps = 8;

View File

@@ -44,6 +44,11 @@ enum ActionCode {
AC_INVALID=100, // invalid state
};
enum ByteOrder {INTEL=0x4949, MOTOROLA=0x4D4D};
#if __BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
const enum ByteOrder HOSTORDER = INTEL;
#else
const enum ByteOrder HOSTORDER = MOTOROLA;
#endif
enum MNKind {NOMK, IFD, HEADERIFD, NIKON3, OLYMPUS2, FUJI,TABLESUBDIR};
bool extractLensInfo(std::string &fullname,double &minFocal, double &maxFocal, double &maxApertureAtMinFocal, double &maxApertureAtMaxFocal);
@@ -193,7 +198,7 @@ class Tag {
unsigned char* getValue () const { return value; }
signed char* getSignedValue () const { return reinterpret_cast<signed char*>(value); }
const TagAttrib* getAttrib () const { return attrib; }
inline ByteOrder getOrder () const { return parent ? parent->getOrder() : INTEL; }
inline ByteOrder getOrder () const { return parent ? parent->getOrder() : HOSTORDER; }
inline TagDirectory* getParent () const { return parent; }
int getValueSize () const { return valuesize; }
bool getOwnMemory () const { return allocOwnMemory; }