From: Fridrich S. <str...@us...> - 2008-07-09 13:46:35
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13560/src/lib Modified Files: Tag: STABLE-0-1-0 WPG2Parser.cpp WPG2Parser.h WPGBitmap.cpp Log Message: Add some useful dump and debug capabilities and fix a wrong seek Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.58.2.7 retrieving revision 1.58.2.8 diff -u -d -r1.58.2.7 -r1.58.2.8 --- WPG2Parser.cpp 11 Dec 2007 14:58:52 -0000 1.58.2.7 +++ WPG2Parser.cpp 9 Jul 2008 13:46:32 -0000 1.58.2.8 @@ -31,12 +31,15 @@ #include <math.h> #include <vector> +#include <sstream> // MSVC++ 6.0 does not have the macro defined, so we define it #ifndef M_PI #define M_PI 3.14159265358979323846 #endif +#define DUMP_BINARY_DATA 1 + static const unsigned char defaultWPG2PaletteRed[] = { 0x00, 0xFF, 0x7F, 0xBF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, @@ -227,7 +230,8 @@ m_bitmap(), m_binaryData(), m_hFlipped(false), - m_vFlipped(false) + m_vFlipped(false), + m_binaryId(0) { } @@ -1785,8 +1789,8 @@ static const char* mimeTypesMap[] = { "", // 0 - "image/x-wpg", - "image/x-wpg", + "", // "image/x-wpg", + "", // "image/x-wpg", "", "", "", // 5 @@ -1830,7 +1834,7 @@ unsigned char description = readU8(); if (description < 0x27) m_binaryData.mimeTypes.push_back(libwpg::WPGString(mimeTypesMap[description])); - m_input->seek(2, WPX_SEEK_CUR); + m_input->seek(7, WPX_SEEK_CUR); } m_binaryData.objectIndex = 0; @@ -1864,8 +1868,10 @@ WPG_DEBUG_MSG((" Image Object Size : %li\n", (unsigned long)binaryData.size())); // temporary for debug - dump the binary data (need to have write access in the current directory -#if 0 - FILE *f = fopen("binarydump", "w"); +#if DUMP_BINARY_DATA + std::ostringstream filename; + filename << "binarydump" << m_binaryId++ << ".bin"; + FILE *f = fopen(filename.str().c_str(), "w"); const char *tmpBinaryBuffer = binaryData.getDataBuffer(); const size_t tmpBufferSize = binaryData.size(); for (size_t k = 0; k < tmpBufferSize; k++) Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.11.2.3 retrieving revision 1.11.2.4 diff -u -d -r1.11.2.3 -r1.11.2.4 --- WPGBitmap.cpp 11 Dec 2007 14:46:31 -0000 1.11.2.3 +++ WPGBitmap.cpp 9 Jul 2008 13:46:32 -0000 1.11.2.4 @@ -27,6 +27,14 @@ #include "WPGBitmap.h" #include "libwpg_utils.h" +#include <sstream> + +#define DUMP_BITMAP 1 + +#if DUMP_BITMAP +static unsigned bitmapId = 0; +#endif + class libwpg::WPGBitmap::Private { public: @@ -201,7 +209,9 @@ base64Encode(bmp, tmpDIBBuffer, tmpDIBFileSize); // temporary for debug - dump the binary bmp (need to have write access in the current directory -#if 0 +#if DUMP_BITMAP + std::ostringstream filename; + filename << "binarydump" << bitmapId++ << ".bmp"; FILE *f = fopen("binarydump.bmp", "w"); for (int k = 0; k < tmpDIBFileSize; k++) fprintf(f, "%c",tmpDIBBuffer[k]); Index: WPG2Parser.h =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.h,v retrieving revision 1.21.2.1 retrieving revision 1.21.2.2 diff -u -d -r1.21.2.1 -r1.21.2.2 --- WPG2Parser.h 11 Dec 2007 14:46:31 -0000 1.21.2.1 +++ WPG2Parser.h 9 Jul 2008 13:46:32 -0000 1.21.2.2 @@ -221,6 +221,7 @@ class ObjectCharacterization; void parseCharacterization(ObjectCharacterization*); + unsigned m_binaryId; }; #endif // __WPG2PARSER_H__ |