parent
d8f10ba4aa
commit
59d4ee5796
@ -1,104 +0,0 @@
|
||||
From a4ab4fdafc33088429a6c6bcdcf3c072b3a834a9 Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Mon, 12 Dec 2016 15:23:55 +0100
|
||||
Subject: [PATCH 2/2] emit bmps with color palette correctly
|
||||
|
||||
Change-Id: I731ab9629fdc08c54b43cdcb21a81633bd89f569
|
||||
---
|
||||
src/lib/VSDContentCollector.cpp | 52 +++++++++++++++++++++++++++++++++++++----
|
||||
src/lib/libvisio_utils.h | 2 ++
|
||||
2 files changed, 50 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/lib/VSDContentCollector.cpp b/src/lib/VSDContentCollector.cpp
|
||||
index c20e626..229120f 100644
|
||||
--- a/src/lib/VSDContentCollector.cpp
|
||||
+++ b/src/lib/VSDContentCollector.cpp
|
||||
@@ -7,6 +7,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
+#include <cassert>
|
||||
#include <string.h> // for memcpy
|
||||
#include <set>
|
||||
#include <stack>
|
||||
@@ -33,6 +34,48 @@ static unsigned bitmapId = 0;
|
||||
|
||||
#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+
|
||||
+unsigned computeBMPDataOffset(librevenge::RVNGInputStream *const input, const unsigned long maxLength)
|
||||
+{
|
||||
+ assert(input);
|
||||
+
|
||||
+ using namespace libvisio;
|
||||
+
|
||||
+ // determine header size
|
||||
+ unsigned headerSize = readU32(input);
|
||||
+ if (headerSize > maxLength)
|
||||
+ headerSize = 40; // assume v.3 bitmap header size
|
||||
+ unsigned off = headerSize;
|
||||
+
|
||||
+ // determine palette size
|
||||
+ input->seek(10, librevenge::RVNG_SEEK_CUR);
|
||||
+ unsigned bpp = readU16(input);
|
||||
+ // sanitize bpp
|
||||
+ if (bpp > 32)
|
||||
+ bpp = 32;
|
||||
+ const unsigned allowedBpp[] = {1, 4, 8, 16, 24, 32};
|
||||
+ size_t bppIdx = 0;
|
||||
+ while (bppIdx < VSD_NUM_ELEMENTS(allowedBpp) && bpp < allowedBpp[bppIdx])
|
||||
+ ++bppIdx;
|
||||
+ if (bpp < allowedBpp[bppIdx])
|
||||
+ bpp = allowedBpp[bppIdx];
|
||||
+ input->seek(16, librevenge::RVNG_SEEK_CUR);
|
||||
+ unsigned paletteColors = readU32(input);
|
||||
+ if (bpp < 16 && paletteColors == 0)
|
||||
+ paletteColors = 1 << bpp;
|
||||
+ assert(maxLength >= off);
|
||||
+ if (paletteColors > 0 && (paletteColors < (maxLength - off) / 4))
|
||||
+ off += 4 * paletteColors;
|
||||
+
|
||||
+ off += 14; // file header size
|
||||
+
|
||||
+ return off;
|
||||
+}
|
||||
+
|
||||
+} // anonymous namespace
|
||||
+
|
||||
libvisio::VSDContentCollector::VSDContentCollector(
|
||||
librevenge::RVNGDrawingInterface *painter,
|
||||
std::vector<std::map<unsigned, XForm> > &groupXFormsSequence,
|
||||
@@ -1359,10 +1402,11 @@ void libvisio::VSDContentCollector::_handleForeignData(const librevenge::RVNGBin
|
||||
m_currentForeignData.append((unsigned char)0x00);
|
||||
m_currentForeignData.append((unsigned char)0x00);
|
||||
|
||||
- m_currentForeignData.append((unsigned char)0x36);
|
||||
- m_currentForeignData.append((unsigned char)0x00);
|
||||
- m_currentForeignData.append((unsigned char)0x00);
|
||||
- m_currentForeignData.append((unsigned char)0x00);
|
||||
+ const unsigned dataOff = computeBMPDataOffset(binaryData.getDataStream(), binaryData.size());
|
||||
+ m_currentForeignData.append((unsigned char)(dataOff & 0xff));
|
||||
+ m_currentForeignData.append((unsigned char)((dataOff >> 8) & 0xff));
|
||||
+ m_currentForeignData.append((unsigned char)((dataOff >> 16) & 0xff));
|
||||
+ m_currentForeignData.append((unsigned char)((dataOff >> 24) & 0xff));
|
||||
}
|
||||
m_currentForeignData.append(binaryData);
|
||||
|
||||
diff --git a/src/lib/libvisio_utils.h b/src/lib/libvisio_utils.h
|
||||
index c6c3a03..2a4880e 100644
|
||||
--- a/src/lib/libvisio_utils.h
|
||||
+++ b/src/lib/libvisio_utils.h
|
||||
@@ -70,6 +70,8 @@ typedef unsigned __int64 uint64_t;
|
||||
#define VSD_DEBUG(M)
|
||||
#endif
|
||||
|
||||
+#define VSD_NUM_ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
|
||||
+
|
||||
namespace libvisio
|
||||
{
|
||||
|
||||
--
|
||||
2.9.3
|
||||
|
@ -1,29 +0,0 @@
|
||||
From f28739d5bcdace1b6aa4671e5c5483d941ca8c6e Mon Sep 17 00:00:00 2001
|
||||
From: David Tardon <dtardon@redhat.com>
|
||||
Date: Tue, 29 Nov 2016 15:05:20 +0100
|
||||
Subject: [PATCH 1/2] fix parsing of text block bg color in some cases
|
||||
|
||||
It appears that if the color index is 0xff, no color should be set.
|
||||
|
||||
Change-Id: I0dcea16ed5d61292d84e82904b863c1ccafd9d7a
|
||||
---
|
||||
src/lib/VSDParser.cpp | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/lib/VSDParser.cpp b/src/lib/VSDParser.cpp
|
||||
index e82a678..8fc73d1 100644
|
||||
--- a/src/lib/VSDParser.cpp
|
||||
+++ b/src/lib/VSDParser.cpp
|
||||
@@ -877,7 +877,8 @@ void libvisio::VSDParser::readTextBlock(librevenge::RVNGInputStream *input)
|
||||
input->seek(1, librevenge::RVNG_SEEK_CUR);
|
||||
double bottomMargin = readDouble(input);
|
||||
unsigned char verticalAlign = readU8(input);
|
||||
- bool isBgFilled = (!!readU8(input));
|
||||
+ const unsigned char bgColourIdx = readU8(input);
|
||||
+ const bool isBgFilled = bgColourIdx != 0 && bgColourIdx != 0xff;
|
||||
Colour c;
|
||||
c.r = readU8(input);
|
||||
c.g = readU8(input);
|
||||
--
|
||||
2.9.3
|
||||
|
Loading…
Reference in new issue