diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-04-04 01:48:47 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-04-04 01:48:47 +0200 |
commit | f06333217ad55e841c4bd5b20b4eebbf7a9ce2f6 (patch) | |
tree | c123253b7bdd4e51520f665982733b8ed83c86d4 | |
parent | ab2f1654645b90409be88686d1189bde01ad173b (diff) |
Working around a CorelDraw x7 bug + fixing palettes
Change-Id: I56ce7bfd3a49923cbf6e989687f02cdcf287eecb
-rw-r--r-- | src/lib/CDRCollector.cpp | 10 | ||||
-rw-r--r-- | src/lib/CDRParser.cpp | 23 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/lib/CDRCollector.cpp b/src/lib/CDRCollector.cpp index 40456cf..01d318b 100644 --- a/src/lib/CDRCollector.cpp +++ b/src/lib/CDRCollector.cpp @@ -477,6 +477,16 @@ unsigned libcdr::CDRParserState::_getRGBColor(const CDRColor &color) blue = col0; break; } + // YIQ + case 0x0a: + { + break; + } + // YIQ255 + case 0x0b: + { + break; + } // Lab case 0x0c: { diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 2c5d231..853c5e0 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -688,7 +688,9 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input if (m_version >= 500) { colorModel = readU16(input); - if (colorModel == 0x19) + if (colorModel == 0x01 && m_version >= 1300) + colorModel = 0x19; + if (colorModel == 0x19 || colorModel == 0x1e) { unsigned char r = 0; unsigned char g = 0; @@ -697,8 +699,19 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input unsigned char m = 0; unsigned char y = 0; unsigned char k = 100; - unsigned short paletteID = readU16(input); - input->seek(4, librevenge::RVNG_SEEK_CUR); + unsigned short paletteID = 0; + /* A bug in CorelDraw x7 creates a corrupted file. If we meet colorModel of 0x1e, + * it is actually colorModel 0x19 and paletteId 0x1e */ + if (colorModel == 0x1e) + { + colorModel = 0x19; + paletteID = 0x1e; + } + else + { + paletteID = readU16(input); + input->seek(4, librevenge::RVNG_SEEK_CUR); + } unsigned short ix = readU16(input); unsigned short tint = readU16(input); switch (paletteID) @@ -1018,11 +1031,11 @@ libcdr::CDRColor libcdr::CDRParser::readColor(librevenge::RVNGInputStream *input red /= 100; green /= 100; blue /= 100; - colorValue = (blue & 0xff); + colorValue = (red & 0xff); colorValue <<= 8; colorValue |= (green & 0xff); colorValue <<= 8; - colorValue |= (red & 0xff); + colorValue |= (blue & 0xff); break; } case 0x09: |