diff options
author | ALONSO Laurent <laurent.alonso@inria.fr> | 2021-09-18 14:00:38 +0200 |
---|---|---|
committer | ALONSO Laurent <laurent.alonso@inria.fr> | 2021-09-18 14:00:38 +0200 |
commit | 41f8aa4dc9203631ade0ac3135c3e92f79bb6858 (patch) | |
tree | d05c1afc9136ec34199777878913baf34de0218d | |
parent | 04029fe202d4dcccdbc78960f35cdbf5e4da3364 (diff) |
picture: try to make some picture dimensions more compatible with LibreOffice
Change-Id: I05e0bb6f8ce0b4715774f1aeb49c47be7bf00213
-rw-r--r-- | src/lib/KEY6Parser.cpp | 1 | ||||
-rw-r--r-- | src/lib/libetonyek_utils.cpp | 17 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/lib/KEY6Parser.cpp b/src/lib/KEY6Parser.cpp index 7bc2e11..a46e462 100644 --- a/src/lib/KEY6Parser.cpp +++ b/src/lib/KEY6Parser.cpp @@ -205,6 +205,7 @@ bool KEY6Parser::parsePlaceholder(const unsigned id) } break; } + // 4: drawable shape default : ETONYEK_DEBUG_MSG(("KEY6Parser::parsePlaceholder: unhandled placeholder type %u\n", type)); break; diff --git a/src/lib/libetonyek_utils.cpp b/src/lib/libetonyek_utils.cpp index 9b789c7..419697e 100644 --- a/src/lib/libetonyek_utils.cpp +++ b/src/lib/libetonyek_utils.cpp @@ -415,8 +415,13 @@ try { len=readU32(stream, true); type=readU32(stream, true); - if (type==0x49454e44) // IEND + if (type==0x49454e44) // IEND + { + // unsure we need to divide by something like 1.7... to be more compatible with LibreOffice + width /= 1.7; + height /= 1.7; break; + } if (type!=0x70485973) // pHYs { if (stream->seek(len+4, librevenge::RVNG_SEEK_CUR)!=0) @@ -435,6 +440,7 @@ try return false; width/=factor[0]; height/=factor[1]; + break; } else return false; @@ -467,8 +473,9 @@ try unsigned unit=readU8(stream); unsigned xPixels=readU16(stream, true); unsigned yPixels=readU16(stream, true); - if (unit==0) // unsure, but this seems more compatible with LibreOffice + if (unit==0) { + // unsure, but this seems more compatible with LibreOffice factor[0]=1.44*double(xPixels)/72; factor[1]=1.44*double(yPixels)/72; } @@ -517,7 +524,11 @@ try else if ((0 == std::memcmp(sig, SIGNATURE_TIFF_1, ETONYEK_NUM_ELEMENTS(SIGNATURE_TIFF_1))) || (0 == std::memcmp(sig, SIGNATURE_TIFF_2, ETONYEK_NUM_ELEMENTS(SIGNATURE_TIFF_2)))) { - // fixme: the code seems ok, but LibreOffice seems to compute the image's dimensions differently :-~ + // fixme: the code seems ok, but sometimes, LibreOffice seems to + // compute the image's dimensions differently :-~ In fact, it does + // not display some TIFF correctly, so as this code is used for + // retrieving cropping, the display of the picture can become + // weirder bool bigEndian=std::memcmp(sig, SIGNATURE_TIFF_2, ETONYEK_NUM_ELEMENTS(SIGNATURE_TIFF_2))==0; stream->seek(4, librevenge::RVNG_SEEK_SET); if (stream->seek(readU32(stream, bigEndian), librevenge::RVNG_SEEK_SET)!=0 || stream->isEnd()) |