summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2011-01-10 18:29:58 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-01-10 18:29:58 +0100
commitf13cb60406a77e490df9d378dbb7405b937a9c0a (patch)
tree7fc1560bda626c734690611a200445189f23bc99
parentbca06a6431824eeb605debb2169e1b63c2ac1353 (diff)
first trial to implement Pict 1 and 2 header reading
-rw-r--r--src/lib/Pict1Parser.cpp142
-rw-r--r--src/lib/Pict2Parser.cpp256
-rw-r--r--src/lib/PictBitmap.cpp6
-rw-r--r--src/lib/PictHeader.cpp155
-rw-r--r--src/lib/PictHeader.h12
-rw-r--r--src/lib/PictImage.cpp43
-rw-r--r--src/lib/PictXParser.cpp8
-rw-r--r--src/lib/libpict_utils.h6
8 files changed, 361 insertions, 267 deletions
diff --git a/src/lib/Pict1Parser.cpp b/src/lib/Pict1Parser.cpp
index 8c217e0..75e5964 100644
--- a/src/lib/Pict1Parser.cpp
+++ b/src/lib/Pict1Parser.cpp
@@ -236,19 +236,19 @@ bool Pict1Parser::parse()
if(handlers[i].type == recordType)
index = i;
- Pict_DEBUG_MSG(("\n"));
+ PICT_DEBUG_MSG(("\n"));
if(index < 0)
- Pict_DEBUG_MSG(("Unknown record type 0x%02x at %li size %d\n",
+ PICT_DEBUG_MSG(("Unknown record type 0x%02x at %li size %d\n",
recordType, recordPos, m_recordLength));
else
{
Method recordHandler = handlers[index].handler;
if(!recordHandler)
- Pict_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %li size %d\n",
+ PICT_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %li size %d\n",
handlers[index].name, recordType, recordPos, m_recordLength));
else
{
- Pict_DEBUG_MSG(("Record '%s' type 0x%02x at %li size %d\n",
+ PICT_DEBUG_MSG(("Record '%s' type 0x%02x at %li size %d\n",
handlers[index].name, recordType, recordPos, m_recordLength));
// invoke the handler for this record
@@ -258,8 +258,8 @@ bool Pict1Parser::parse()
//if(m_input->tell() > m_recordEnd+1)
{
- //Pict_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType));
- Pict_DEBUG_MSG(("Current stream position: %li\n", m_input->tell()));
+ //PICT_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType));
+ PICT_DEBUG_MSG(("Current stream position: %li\n", m_input->tell()));
}
if(m_exit) break;
@@ -292,7 +292,7 @@ void Pict1Parser::handleStartPict()
m_painter->startGraphics(propList);
m_graphicsStarted = true;
- Pict_DEBUG_MSG(("StartPict\n"));
+ PICT_DEBUG_MSG(("StartPict\n"));
}
void Pict1Parser::handleEndPict()
@@ -302,7 +302,7 @@ void Pict1Parser::handleEndPict()
m_painter->endGraphics();
m_exit = true;
- Pict_DEBUG_MSG(("EndPict\n"));
+ PICT_DEBUG_MSG(("EndPict\n"));
}
void Pict1Parser::handleColormap()
@@ -314,7 +314,7 @@ void Pict1Parser::handleColormap()
if (startIndex > 255 || numEntries > 256 || startIndex + numEntries > 256)
return;
- Pict_DEBUG_MSG(("Colormap\n"));
+ PICT_DEBUG_MSG(("Colormap\n"));
for(unsigned int i = 0; i < numEntries; i++)
{
unsigned char red = readU8();
@@ -322,7 +322,7 @@ void Pict1Parser::handleColormap()
unsigned char blue = readU8();
libpict::PictColor color(red, green, blue);
m_colorPalette[startIndex+i] = color;
- Pict_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr()));
+ PICT_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr()));
}
}
@@ -342,9 +342,9 @@ void Pict1Parser::handleFillAttributes()
m_style.insert("draw:fill-color", m_brushForeColor.getColorString());
m_style.insert("draw:opacity", m_brushForeColor.getOpacity(), WPX_PERCENT);
- Pict_DEBUG_MSG(("Fill Attributes\n"));
- Pict_DEBUG_MSG((" Fill style: %d\n", style));
- Pict_DEBUG_MSG((" Fill color index: %d\n", color));
+ PICT_DEBUG_MSG(("Fill Attributes\n"));
+ PICT_DEBUG_MSG((" Fill style: %d\n", style));
+ PICT_DEBUG_MSG((" Fill color index: %d\n", color));
}
void Pict1Parser::handleLineAttributes()
@@ -365,10 +365,10 @@ void Pict1Parser::handleLineAttributes()
else
m_style.insert("svg:stroke-width", (double)width / 1200.0);
- Pict_DEBUG_MSG(("Line Attributes\n"));
- Pict_DEBUG_MSG((" Line style: %d\n", style));
- Pict_DEBUG_MSG((" Line color index: %d\n", color));
- Pict_DEBUG_MSG((" Line width: %d\n", width));
+ PICT_DEBUG_MSG(("Line Attributes\n"));
+ PICT_DEBUG_MSG((" Line style: %d\n", style));
+ PICT_DEBUG_MSG((" Line color index: %d\n", color));
+ PICT_DEBUG_MSG((" Line width: %d\n", width));
}
void Pict1Parser::handleLine()
@@ -394,9 +394,9 @@ void Pict1Parser::handleLine()
m_painter->drawPolyline(points);
- Pict_DEBUG_MSG(("Line\n"));
- Pict_DEBUG_MSG((" Starting point: %d,%d\n", sx, sy));
- Pict_DEBUG_MSG((" End point: %d,%d\n", ex, ey));
+ PICT_DEBUG_MSG(("Line\n"));
+ PICT_DEBUG_MSG((" Starting point: %d,%d\n", sx, sy));
+ PICT_DEBUG_MSG((" End point: %d,%d\n", ex, ey));
}
void Pict1Parser::handlePolyline()
@@ -421,7 +421,7 @@ void Pict1Parser::handlePolyline()
m_painter->drawPolyline(points);
- Pict_DEBUG_MSG(("Polyline\n"));
+ PICT_DEBUG_MSG(("Polyline\n"));
}
void Pict1Parser::handleRectangle()
@@ -444,10 +444,10 @@ void Pict1Parser::handleRectangle()
m_painter->drawRectangle(propList);
- Pict_DEBUG_MSG(("Line\n"));
- Pict_DEBUG_MSG((" Corner point: %d,%d\n", x, y));
- Pict_DEBUG_MSG((" Width: %d\n", w));
- Pict_DEBUG_MSG((" Height: %d\n", h));
+ PICT_DEBUG_MSG(("Line\n"));
+ PICT_DEBUG_MSG((" Corner point: %d,%d\n", x, y));
+ PICT_DEBUG_MSG((" Width: %d\n", w));
+ PICT_DEBUG_MSG((" Height: %d\n", h));
}
void Pict1Parser::handlePolygon()
@@ -472,7 +472,7 @@ void Pict1Parser::handlePolygon()
m_painter->drawPolygon(points);
- Pict_DEBUG_MSG(("Polygon\n"));
+ PICT_DEBUG_MSG(("Polygon\n"));
}
void Pict1Parser::handleEllipse()
@@ -496,10 +496,10 @@ void Pict1Parser::handleEllipse()
m_painter->drawEllipse(propList);
- Pict_DEBUG_MSG(("Ellipse\n"));
- Pict_DEBUG_MSG((" Center point: %s,%s\n", propList["svg:cx"]->getStr().cstr(), propList["svg:cy"]->getStr().cstr()));
- Pict_DEBUG_MSG((" Radius x: %s\n", propList["svg:rx"]->getStr().cstr()));
- Pict_DEBUG_MSG((" Radius y: %s\n", propList["svg:ry"]->getStr().cstr()));
+ PICT_DEBUG_MSG(("Ellipse\n"));
+ PICT_DEBUG_MSG((" Center point: %s,%s\n", propList["svg:cx"]->getStr().cstr(), propList["svg:cy"]->getStr().cstr()));
+ PICT_DEBUG_MSG((" Radius x: %s\n", propList["svg:rx"]->getStr().cstr()));
+ PICT_DEBUG_MSG((" Radius y: %s\n", propList["svg:ry"]->getStr().cstr()));
}
void Pict1Parser::handleCurvedPolyline()
@@ -544,7 +544,7 @@ void Pict1Parser::handleCurvedPolyline()
m_painter->drawPath(path);
- Pict_DEBUG_MSG(("Curved Polyline\n"));
+ PICT_DEBUG_MSG(("Curved Polyline\n"));
}
void Pict1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width, unsigned height, unsigned depth)
@@ -558,10 +558,10 @@ void Pict1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width,
// round to the next byte
unsigned scanline_width = (width * depth + 7)/8;
unsigned tmpBufferSize = scanline_width * height;
- Pict_DEBUG_MSG(("Scanline width: %d\n", scanline_width));
- Pict_DEBUG_MSG(("Output size: %d\n", scanline_width * height));
+ PICT_DEBUG_MSG(("Scanline width: %d\n", scanline_width));
+ PICT_DEBUG_MSG(("Output size: %d\n", scanline_width * height));
- Pict_DEBUG_MSG(("Decoding RLE data\n"));
+ PICT_DEBUG_MSG(("Decoding RLE data\n"));
buffer.reserve(tmpBufferSize);
while (m_input->tell() < m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize)
@@ -593,7 +593,7 @@ void Pict1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width,
count = (int)readU8();
if (buffer.size() < scanline_width )
{
- Pict_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size()));
+ PICT_DEBUG_MSG(("Cannot copy the scanline, not enough data %li\n", (long)buffer.size()));
break;
}
unsigned raster_source = buffer.size() - scanline_width;
@@ -606,8 +606,8 @@ void Pict1Parser::decodeRLE(std::vector<unsigned char>& buffer, unsigned width,
}
}
}
- Pict_DEBUG_MSG(("Finish decoding RLE data\n"));
- Pict_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size()));
+ PICT_DEBUG_MSG(("Finish decoding RLE data\n"));
+ PICT_DEBUG_MSG(("Buffer length: %li\n", (long)buffer.size()));
while (buffer.size() < tmpBufferSize)
buffer.push_back(0);
@@ -694,12 +694,12 @@ void Pict1Parser::handleBitmapTypeOne()
int hres = readS16();
int vres = readS16();
- Pict_DEBUG_MSG(("Bitmap\n"));
- Pict_DEBUG_MSG((" Width: %d\n", width));
- Pict_DEBUG_MSG((" Height: %d\n", height));
- Pict_DEBUG_MSG((" Depth: %d\n", depth));
- Pict_DEBUG_MSG(("Horizontal resolution: %d\n", hres));
- Pict_DEBUG_MSG((" Vertical resolution: %d\n", vres));
+ PICT_DEBUG_MSG(("Bitmap\n"));
+ PICT_DEBUG_MSG((" Width: %d\n", width));
+ PICT_DEBUG_MSG((" Height: %d\n", height));
+ PICT_DEBUG_MSG((" Depth: %d\n", depth));
+ PICT_DEBUG_MSG(("Horizontal resolution: %d\n", hres));
+ PICT_DEBUG_MSG((" Vertical resolution: %d\n", vres));
// if this happens, likely corruption, bail out.
if (depth != 1 && depth != 2 && depth != 4 && depth != 8)
@@ -752,15 +752,15 @@ void Pict1Parser::handleBitmapTypeTwo()
int hres = readS16();
int vres = readS16();
- Pict_DEBUG_MSG(("Bitmap\n"));
- Pict_DEBUG_MSG((" Rotation Angle: %d\n", rotation));
- Pict_DEBUG_MSG((" Top left corner: %d,%d\n", x1, y1));
- Pict_DEBUG_MSG((" Bottom right corner: %d,%d\n", x2, y2));
- Pict_DEBUG_MSG((" Width: %d\n", width));
- Pict_DEBUG_MSG((" Height: %d\n", height));
- Pict_DEBUG_MSG((" Depth: %d\n", depth));
- Pict_DEBUG_MSG(("Horizontal resolution: %d\n", hres));
- Pict_DEBUG_MSG((" Vertical resolution: %d\n", vres));
+ PICT_DEBUG_MSG(("Bitmap\n"));
+ PICT_DEBUG_MSG((" Rotation Angle: %d\n", rotation));
+ PICT_DEBUG_MSG((" Top left corner: %d,%d\n", x1, y1));
+ PICT_DEBUG_MSG((" Bottom right corner: %d,%d\n", x2, y2));
+ PICT_DEBUG_MSG((" Width: %d\n", width));
+ PICT_DEBUG_MSG((" Height: %d\n", height));
+ PICT_DEBUG_MSG((" Depth: %d\n", depth));
+ PICT_DEBUG_MSG(("Horizontal resolution: %d\n", hres));
+ PICT_DEBUG_MSG((" Vertical resolution: %d\n", vres));
// if this happens, likely corruption, bail out.
if (rotation < 0 || rotation > 359)
@@ -787,7 +787,7 @@ void Pict1Parser::handleBitmapTypeTwo()
long xs2 = (x1 <= x2) ? x2 : x1;
long ys1 = (y1 <= y2) ? y1 : y2;
long ys2 = (y1 <= y2) ? y2 : y1;
- Pict_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2));
+ PICT_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2));
libpict::PictBitmap bitmap(width, height, vres, hres);
::WPXPropertyList propList;
@@ -847,11 +847,11 @@ void Pict1Parser::handlePostscriptTypeTwo()
int x2 = readS16();
int y2 = readS16();
- Pict_DEBUG_MSG(("Postscript (Type 2)\n"));
- Pict_DEBUG_MSG((" Length of Data: %d\n", lengthOfData));
- Pict_DEBUG_MSG((" Rotation Angle: %d\n", rotation));
- Pict_DEBUG_MSG((" Bottom left corner: %d,%d\n", x1, y1));
- Pict_DEBUG_MSG((" Top right corner: %d,%d\n", x2, y2));
+ PICT_DEBUG_MSG(("Postscript (Type 2)\n"));
+ PICT_DEBUG_MSG((" Length of Data: %d\n", lengthOfData));
+ PICT_DEBUG_MSG((" Rotation Angle: %d\n", rotation));
+ PICT_DEBUG_MSG((" Bottom left corner: %d,%d\n", x1, y1));
+ PICT_DEBUG_MSG((" Top right corner: %d,%d\n", x2, y2));
y1 = m_height - y1;
y2 = m_height - y2;
@@ -860,7 +860,7 @@ void Pict1Parser::handlePostscriptTypeTwo()
long xs2 = (x1 <= x2) ? x2 : x1;
long ys1 = (y1 <= y2) ? y1 : y2;
long ys2 = (y1 <= y2) ? y2 : y1;
- Pict_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2));
+ PICT_DEBUG_MSG(("%li %li %li %li\n", xs1, ys1, xs2, ys2));
::WPXPropertyList propList;
@@ -899,10 +899,10 @@ void Pict1Parser::handleGraphicsTextTypeOne()
for (unsigned short i=0; i < textLength; i++)
textString.append(readU8());
- Pict_DEBUG_MSG(("Graphics Text (Type 1)\n"));
- Pict_DEBUG_MSG((" Length of String: %d\n", textLength));
- Pict_DEBUG_MSG((" String position: %d,%d\n", x, y));
- Pict_DEBUG_MSG((" String: %s\n", textString.cstr()));
+ PICT_DEBUG_MSG(("Graphics Text (Type 1)\n"));
+ PICT_DEBUG_MSG((" Length of String: %d\n", textLength));
+ PICT_DEBUG_MSG((" String position: %d,%d\n", x, y));
+ PICT_DEBUG_MSG((" String: %s\n", textString.cstr()));
y = m_height - y;
@@ -940,14 +940,14 @@ void Pict1Parser::handleGraphicsTextTypeTwo()
for (unsigned short i=0; i < textLength; i++)
textString.append(readU8());
- Pict_DEBUG_MSG(("Graphics Text (Type 1)\n"));
- Pict_DEBUG_MSG((" Size of Equivalent data: %d\n", sizeEquivalentData));
- Pict_DEBUG_MSG((" Rotation Angle: %d\n", rotationAngle));
- Pict_DEBUG_MSG((" Length of String: %d\n", textLength));
- Pict_DEBUG_MSG((" Start position: %d,%d\n", x1, y1));
- Pict_DEBUG_MSG((" End position: %d,%d\n", x2, y2));
- Pict_DEBUG_MSG((" Scale factor: %d,%d\n", sx, sy));
- Pict_DEBUG_MSG((" Type: %d\n", type));
+ PICT_DEBUG_MSG(("Graphics Text (Type 1)\n"));
+ PICT_DEBUG_MSG((" Size of Equivalent data: %d\n", sizeEquivalentData));
+ PICT_DEBUG_MSG((" Rotation Angle: %d\n", rotationAngle));
+ PICT_DEBUG_MSG((" Length of String: %d\n", textLength));
+ PICT_DEBUG_MSG((" Start position: %d,%d\n", x1, y1));
+ PICT_DEBUG_MSG((" End position: %d,%d\n", x2, y2));
+ PICT_DEBUG_MSG((" Scale factor: %d,%d\n", sx, sy));
+ PICT_DEBUG_MSG((" Type: %d\n", type));
// PictTextDataHandler handler(m_painter);
// WPDocument::parseSubDocument(const_cast<WPXInputStream *>(textString.getDataStream()), &handler, WPD_FILE_FORMAT_WP5);
diff --git a/src/lib/Pict2Parser.cpp b/src/lib/Pict2Parser.cpp
index 19cb03b..0e43205 100644
--- a/src/lib/Pict2Parser.cpp
+++ b/src/lib/Pict2Parser.cpp
@@ -373,10 +373,10 @@ bool Pict2Parser::parse()
if(handlers[i].type == recordType)
index = i;
- Pict_DEBUG_MSG(("\n"));
+ PICT_DEBUG_MSG(("\n"));
if(index < 0)
{
- Pict_DEBUG_MSG(("Unknown record type 0x%02x at %li size %d extension %d\n",
+ PICT_DEBUG_MSG(("Unknown record type 0x%02x at %li size %d extension %d\n",
recordType, recordPos, m_recordLength, extension));
}
else
@@ -384,11 +384,11 @@ bool Pict2Parser::parse()
Method recordHandler = handlers[index].handler;
if(!recordHandler)
- Pict_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %li size %d extension %d\n",
+ PICT_DEBUG_MSG(("Record '%s' (ignored) type 0x%02x at %li size %d extension %d\n",
handlers[index].name, recordType, recordPos, m_recordLength, extension));
else
{
- Pict_DEBUG_MSG(("Record '%s' type 0x%02x at %li size %d extension %d\n",
+ PICT_DEBUG_MSG(("Record '%s' type 0x%02x at %li size %d extension %d\n",
handlers[index].name, recordType, recordPos, m_recordLength, extension));
// invoke the handler for this record
@@ -426,8 +426,8 @@ bool Pict2Parser::parse()
//if(m_input->tell() > m_recordEnd+1)
{
- //Pict_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType));
- Pict_DEBUG_MSG(("Current stream position: %li\n", m_input->tell()));
+ //PICT_DEBUG_MSG(("Record 0x%x consumes more bytes than necessary!\n", recordType));
+ PICT_DEBUG_MSG(("Current stream position: %li\n", m_input->tell()));
}
if(m_exit) break;
@@ -497,7 +497,7 @@ void Pict2Parser::handleStartPict()
if((horizontalUnit==0) || (verticalUnit==0))
{
m_xres = m_yres = 1200;
- Pict_DEBUG_MSG(("Warning ! Insane unit of measure"));
+ PICT_DEBUG_MSG(("Warning ! Insane unit of measure"));
}
// danger if we do not recognize the precision code
@@ -528,22 +528,22 @@ void Pict2Parser::handleStartPict()
m_width = (imageX2 > imageX1 ) ? imageX2-imageX1 : imageX1-imageX2;
m_height = (imageY2 > imageY1) ? imageY2-imageY1 : imageY1-imageY2;
- Pict_DEBUG_MSG(("StartPict 2\n"));
- Pict_DEBUG_MSG((" Horizontal unit of measure : %d pixels/inch\n", horizontalUnit));
- Pict_DEBUG_MSG((" Vertical unit of measure : %d pixels/inch\n", verticalUnit));
- Pict_DEBUG_MSG((" Data precision : %d (%s)\n", precision, describePrecision(precision)));
- Pict_DEBUG_MSG((" Viewport X1 : %li\n", viewportX1));
- Pict_DEBUG_MSG((" Viewport Y1 : %li\n", viewportY1));
- Pict_DEBUG_MSG((" Viewport X2 : %li\n", viewportX2));
- Pict_DEBUG_MSG((" Viewport Y2 : %li\n", viewportY2));
- Pict_DEBUG_MSG((" Image X1 : %li\n", imageX1));
- Pict_DEBUG_MSG((" Image Y1 : %li\n", imageY1));
- Pict_DEBUG_MSG((" Image X2 : %li\n", imageX2));
- Pict_DEBUG_MSG((" Image Y2 : %li\n", imageY2));
- Pict_DEBUG_MSG((" X offset : %li\n", m_xofs));
- Pict_DEBUG_MSG((" Y offset : %li\n", m_yofs));
- Pict_DEBUG_MSG((" width : %li\n", m_width));
- Pict_DEBUG_MSG((" height : %li\n", m_height));
+ PICT_DEBUG_MSG(("StartPict 2\n"));
+ PICT_DEBUG_MSG((" Horizontal unit of measure : %d pixels/inch\n", horizontalUnit));
+ PICT_DEBUG_MSG((" Vertical unit of measure : %d pixels/inch\n", verticalUnit));
+ PICT_DEBUG_MSG((" Data precision : %d (%s)\n", precision, describePrecision(precision)));
+ PICT_DEBUG_MSG((" Viewport X1 : %li\n", viewportX1));
+ PICT_DEBUG_MSG((" Viewport Y1 : %li\n", viewportY1));
+ PICT_DEBUG_MSG((" Viewport X2 : %li\n", viewportX2));
+ PICT_DEBUG_MSG((" Viewport Y2 : %li\n", viewportY2));
+ PICT_DEBUG_MSG((" Image X1 : %li\n", imageX1));
+ PICT_DEBUG_MSG((" Image Y1 : %li\n", imageY1));
+ PICT_DEBUG_MSG((" Image X2 : %li\n", imageX2));
+ PICT_DEBUG_MSG((" Image Y2 : %li\n", imageY2));
+ PICT_DEBUG_MSG((" X offset : %li\n", m_xofs));
+ PICT_DEBUG_MSG((" Y offset : %li\n", m_yofs));
+ PICT_DEBUG_MSG((" width : %li\n", m_width));
+ PICT_DEBUG_MSG((" height : %li\n", m_height));
::WPXPropertyList propList;
propList.insert("svg:width", ((TO_DOUBLE(m_width)) / m_xres));
@@ -615,8 +615,8 @@ void Pict2Parser::handleFormSettings()
double margT = (TO_DOUBLE(mt)) / m_xres;
double margB = (TO_DOUBLE(mb)) / m_xres;
- Pict_DEBUG_MSG(("Form Settings: width: %f height : %f\n", width, height));
- Pict_DEBUG_MSG(("Form Margins: left: %f right : %f top: %f bottom: %f\n", margL, margR, margT, margB));
+ PICT_DEBUG_MSG(("Form Settings: width: %f height : %f\n", width, height));
+ PICT_DEBUG_MSG(("Form Margins: left: %f right : %f top: %f bottom: %f\n", margL, margR, margT, margB));
#endif
}
@@ -634,7 +634,7 @@ void Pict2Parser::handleLayer()
m_painter->startLayer(propList);
m_layerOpened = true;
- Pict_DEBUG_MSG((" Layer Id: %d\n", m_layerId));
+ PICT_DEBUG_MSG((" Layer Id: %d\n", m_layerId));
}
void Pict2Parser::handleCompoundPolygon()
@@ -695,8 +695,8 @@ void Pict2Parser::handlePenStyleDefinition()
}
m_dashArrayStyles[style] = dashArray;
- Pict_DEBUG_MSG((" Style : %d\n", style));
- Pict_DEBUG_MSG((" Segment pairs : %d\n", segments));
+ PICT_DEBUG_MSG((" Style : %d\n", style));
+ PICT_DEBUG_MSG((" Segment pairs : %d\n", segments));
}
#if 0
@@ -705,7 +705,7 @@ void Pict2Parser::handlePatternDefinition()
{
if (!m_graphicsStarted)
return;
- Pict_DEBUG_MSG(("PatternDefinition\n"));
+ PICT_DEBUG_MSG(("PatternDefinition\n"));
}
#endif
@@ -724,7 +724,7 @@ void Pict2Parser::handleColorPalette()
unsigned char alpha = 0xff - readU8();
libpict::PictColor color(red, green, blue, alpha);
m_colorPalette[startIndex+i] = color;
- Pict_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr()));
+ PICT_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr()));
}
}
@@ -743,7 +743,7 @@ void Pict2Parser::handleDPColorPalette()
unsigned char alpha = 0xff - (readU16() >> 8) ;
libpict::PictColor color(red, green, blue, alpha);
m_colorPalette[startIndex+i] = color;
- Pict_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr()));
+ PICT_DEBUG_MSG(("Index#%d: RGB %s\n", startIndex+i, color.getColorString().cstr()));
}
}
@@ -765,7 +765,7 @@ void Pict2Parser::handlePenForeColor()
m_penForeColor = libpict::PictColor(red, green, blue, alpha);
- Pict_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
}
void Pict2Parser::handleDPPenForeColor()
@@ -789,7 +789,7 @@ void Pict2Parser::handleDPPenForeColor()
m_style.insert("svg:stroke-opacity", libpict::PictColor(red, green, blue, alpha).getOpacity(), WPX_PERCENT);
m_penForeColor = libpict::PictColor(red, green, blue, alpha);
- Pict_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
}
void Pict2Parser::handlePenBackColor()
@@ -810,7 +810,7 @@ void Pict2Parser::handlePenBackColor()
m_style.insert("svg:stroke-color", m_penForeColor.getColorString());
m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT);
- Pict_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
#endif
}
@@ -833,7 +833,7 @@ void Pict2Parser::handleDPPenBackColor()
m_style.insert("svg:stroke-color", m_penForeColor.getColorString());
m_style.insert("svg:stroke-opacity", m_penForeColor.getOpacity(), WPX_PERCENT);
- Pict_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
#endif
}
@@ -855,8 +855,8 @@ void Pict2Parser::handlePenStyle()
if (!style)
m_style.insert("draw:stroke", "solid");
- Pict_DEBUG_MSG((" Pen style : %d\n", style));
- Pict_DEBUG_MSG((" Segments : %d\n", m_dashArray.count()));
+ PICT_DEBUG_MSG((" Pen style : %d\n", style));
+ PICT_DEBUG_MSG((" Segments : %d\n", m_dashArray.count()));
}
void Pict2Parser::handlePenSize()
@@ -874,7 +874,7 @@ void Pict2Parser::handlePenSize()
m_style.insert("svg:stroke-width", (TO_DOUBLE(width) / m_xres));
- Pict_DEBUG_MSG((" Width: %d\n", width));
+ PICT_DEBUG_MSG((" Width: %d\n", width));
}
void Pict2Parser::handleDPPenSize()
@@ -893,7 +893,7 @@ void Pict2Parser::handleDPPenSize()
m_style.insert("svg:stroke-width", TO_DOUBLE(width) / m_xres / 256);
// m_pen.height = TO_DOUBLE(height) / m_yres / 256;
- Pict_DEBUG_MSG((" Width: %li\n", width));
+ PICT_DEBUG_MSG((" Width: %li\n", width));
}
void Pict2Parser::handleLineCap()
@@ -907,7 +907,7 @@ void Pict2Parser::handleLineCap()
if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
return;
}
-// Pict_DEBUG_MSG((" Line cap : %d\n", style));
+// PICT_DEBUG_MSG((" Line cap : %d\n", style));
}
void Pict2Parser::handleLineJoin()
@@ -921,7 +921,7 @@ void Pict2Parser::handleLineJoin()
if (m_groupStack.top().parentType == 0x01) // we don't handle Page Attributes for now
return;
}
-// Pict_DEBUG_MSG((" Line join : %d\n", style));
+// PICT_DEBUG_MSG((" Line join : %d\n", style));
}
void Pict2Parser::handleBrushGradient()
@@ -953,10 +953,10 @@ void Pict2Parser::handleBrushGradient()
m_gradientRef.insert("svg:x", (double)xref);
m_gradientRef.insert("svg:y", (double)yref);
- Pict_DEBUG_MSG((" Gradient angle : %d.%d\n", angleInteger, angleFraction));
- Pict_DEBUG_MSG((" Gradient reference : %d.%d\n", xref, yref));
- Pict_DEBUG_MSG((" Granular : %s\n", (granular ? "yes" : "no")));
- Pict_DEBUG_MSG((" Anchored : %s\n", (anchor ? "yes" : "no")));
+ PICT_DEBUG_MSG((" Gradient angle : %d.%d\n", angleInteger, angleFraction));
+ PICT_DEBUG_MSG((" Gradient reference : %d.%d\n", xref, yref));
+ PICT_DEBUG_MSG((" Granular : %s\n", (granular ? "yes" : "no")));
+ PICT_DEBUG_MSG((" Anchored : %s\n", (anchor ? "yes" : "no")));
}
void Pict2Parser::handleDPBrushGradient()
@@ -988,10 +988,10 @@ void Pict2Parser::handleDPBrushGradient()
m_gradientRef.insert("svg:x", (double)xref);
m_gradientRef.insert("svg:y", (double)yref);
- Pict_DEBUG_MSG((" Gradient angle : %d.%d\n", angleInteger, angleFraction));
- Pict_DEBUG_MSG((" Gradient reference : %d.%d\n", xref, yref));
- Pict_DEBUG_MSG((" Granular : %s\n", (granular ? "yes" : "no")));
- Pict_DEBUG_MSG((" Anchored : %s\n", (anchor ? "yes" : "no")));
+ PICT_DEBUG_MSG((" Gradient angle : %d.%d\n", angleInteger, angleFraction));
+ PICT_DEBUG_MSG((" Gradient reference : %d.%d\n", xref, yref));
+ PICT_DEBUG_MSG((" Granular : %s\n", (granular ? "yes" : "no")));
+ PICT_DEBUG_MSG((" Anchored : %s\n", (anchor ? "yes" : "no")));
}
void Pict2Parser::handleBrushForeColor()
@@ -1006,7 +1006,7 @@ void Pict2Parser::handleBrushForeColor()
return;
}
unsigned char gradientType = readU8();
- Pict_DEBUG_MSG((" Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
+ PICT_DEBUG_MSG((" Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
if(gradientType == 0)
{
@@ -1014,7 +1014,7 @@ void Pict2Parser::handleBrushForeColor()
unsigned char green = readU8();
unsigned char blue = readU8();
unsigned char alpha = 0xff - readU8();
- Pict_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
m_brushForeColor = libpict::PictColor(red, green, blue, alpha);
@@ -1029,7 +1029,7 @@ void Pict2Parser::handleBrushForeColor()
unsigned count = readU16();
std::vector<libpict::PictColor> colors;
std::vector<double> positions;
- Pict_DEBUG_MSG((" Gradient colors : %d\n", count));
+ PICT_DEBUG_MSG((" Gradient colors : %d\n", count));
if (count > 0)
{
@@ -1041,14 +1041,14 @@ void Pict2Parser::handleBrushForeColor()
unsigned char alpha = 0xff - readU8();
libpict::PictColor color(red, green, blue, alpha);
colors.push_back(color);
- Pict_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha));
}
for(unsigned j = 0; j < count-1; j++)
{
unsigned pos = readU16();
positions.push_back(TO_DOUBLE(pos));
- Pict_DEBUG_MSG((" Position #%d : %d\n", j+1, pos));
+ PICT_DEBUG_MSG((" Position #%d : %d\n", j+1, pos));
}
}
@@ -1099,7 +1099,7 @@ void Pict2Parser::handleDPBrushForeColor()
return;
}
unsigned char gradientType = readU8();
- Pict_DEBUG_MSG((" Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
+ PICT_DEBUG_MSG((" Gradient type : %d (%s)\n", gradientType, describeGradient(gradientType)));
if(gradientType == 0)
{
@@ -1107,7 +1107,7 @@ void Pict2Parser::handleDPBrushForeColor()
unsigned char green = (m_doublePrecision) ? readU16()>>8 : readU8();
unsigned char blue = (m_doublePrecision) ? readU16()>>8 : readU8();
unsigned char alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8();
- Pict_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Foreground color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
m_brushForeColor = libpict::PictColor(red, green, blue, alpha);
@@ -1122,7 +1122,7 @@ void Pict2Parser::handleDPBrushForeColor()
unsigned count = readU16();
std::vector<libpict::PictColor> colors;
std::vector<double> positions;
- Pict_DEBUG_MSG((" Gradient colors : %d\n", count));
+ PICT_DEBUG_MSG((" Gradient colors : %d\n", count));
if (count > 0)
{
@@ -1134,14 +1134,14 @@ void Pict2Parser::handleDPBrushForeColor()
unsigned char alpha = 0xff - (m_doublePrecision) ? readU16()>>8 : readU8();
libpict::PictColor color(red, green, blue, alpha);
colors.push_back(color);
- Pict_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha));
}
for(unsigned j = 0; j < count-1; j++)
{
unsigned pos = readU16();
positions.push_back(TO_DOUBLE(pos));
- Pict_DEBUG_MSG((" Position #%d : %d\n", j+1, pos));
+ PICT_DEBUG_MSG((" Position #%d : %d\n", j+1, pos));
}
}
@@ -1199,7 +1199,7 @@ void Pict2Parser::handleBrushBackColor()
if(m_gradient.style == libpict::PictGradient::NoBrush)
m_gradient.style = libpict::PictGradient::Solid;
- Pict_DEBUG_MSG((" Backround color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Backround color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
#endif
}
@@ -1224,7 +1224,7 @@ void Pict2Parser::handleDPBrushBackColor()
if(m_style["draw:fill"] && m_style["draw:fill"]->getStr() == "none")
m_style.insert("draw:fill", "solid");
- Pict_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
+ PICT_DEBUG_MSG((" Background color (RGBA): %d %d %d %d\n", red, green, blue, alpha));
#endif
}
@@ -1245,7 +1245,7 @@ void Pict2Parser::handleBrushPattern()
// TODO
- Pict_DEBUG_MSG((" Pattern : %d\n", pattern));
+ PICT_DEBUG_MSG((" Pattern : %d\n", pattern));
}
void Pict2Parser::parseCharacterization(ObjectCharacterization* ch)
@@ -1311,27 +1311,27 @@ void Pict2Parser::parseCharacterization(ObjectCharacterization* ch)
ch->matrix.element[1][2] = (double)(ch->py);
}
- Pict_DEBUG_MSG(("ObjectCharacterization\n"));
- Pict_DEBUG_MSG((" taper : %s\n", (ch->taper ? "yes" : "no")));
- Pict_DEBUG_MSG((" translate : %s\n", (ch->translate ? "yes" : "no")));
- Pict_DEBUG_MSG((" skew : %s\n", (ch->skew ? "yes" : "no")));
- Pict_DEBUG_MSG((" scale : %s\n", (ch->scale ? "yes" : "no")));
- Pict_DEBUG_MSG((" rotate : %s\n", (ch->rotate ? "yes" : "no")));
- Pict_DEBUG_MSG((" hasObjectId : %s\n", (ch->hasObjectId ? "yes" : "no")));
- Pict_DEBUG_MSG((" editLock : %s\n", (ch->editLock ? "yes" : "no")));
- Pict_DEBUG_MSG((" closed : %s\n", (ch->closed ? "yes" : "no")));
- Pict_DEBUG_MSG((" framed : %s\n", (ch->framed ? "yes" : "no")));
- Pict_DEBUG_MSG((" filled : %s\n", (ch->filled ? "yes" : "no")));
+ PICT_DEBUG_MSG(("ObjectCharacterization\n"));
+ PICT_DEBUG_MSG((" taper : %s\n", (ch->taper ? "yes" : "no")));
+ PICT_DEBUG_MSG((" translate : %s\n", (ch->translate ? "yes" : "no")));
+ PICT_DEBUG_MSG((" skew : %s\n", (ch->skew ? "yes" : "no")));
+ PICT_DEBUG_MSG((" scale : %s\n", (ch->scale ? "yes" : "no")));
+ PICT_DEBUG_MSG((" rotate : %s\n", (ch->rotate ? "yes" : "no")));
+ PICT_DEBUG_MSG((" hasObjectId : %s\n", (ch->hasObjectId ? "yes" : "no")));
+ PICT_DEBUG_MSG((" editLock : %s\n", (ch->editLock ? "yes" : "no")));
+ PICT_DEBUG_MSG((" closed : %s\n", (ch->closed ? "yes" : "no")));
+ PICT_DEBUG_MSG((" framed : %s\n", (ch->framed ? "yes" : "no")));
+ PICT_DEBUG_MSG((" filled : %s\n", (ch->filled ? "yes" : "no")));
#ifdef DEBUG
- if(ch->editLock) Pict_DEBUG_MSG((" lock flags : 0x%x\n", (unsigned)ch->lockFlags));
- if(ch->hasObjectId) Pict_DEBUG_MSG((" object ID : 0x%x\n", (unsigned)ch->objectId));
- if(ch->translate) Pict_DEBUG_MSG((" tx : %li %d\n", ch->txinteger, ch->txfraction));
- if(ch->translate) Pict_DEBUG_MSG((" ty : %li %d\n", ch->tyinteger, ch->tyfraction));
+ if(ch->editLock) PICT_DEBUG_MSG((" lock flags : 0x%x\n", (unsigned)ch->lockFlags));
+ if(ch->hasObjectId) PICT_DEBUG_MSG((" object ID : 0x%x\n", (unsigned)ch->objectId));
+ if(ch->translate) PICT_DEBUG_MSG((" tx : %li %d\n", ch->txinteger, ch->txfraction));
+ if(ch->translate) PICT_DEBUG_MSG((" ty : %li %d\n", ch->tyinteger, ch->tyfraction));
#endif
- Pict_DEBUG_MSG(("transform matrix:\n"));
- Pict_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[0][0], ch->matrix.element[0][1],ch->matrix.element[0][2]));
- Pict_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[1][0], ch->matrix.element[1][1],ch->matrix.element[1][2]));
- Pict_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[2][0], ch->matrix.element[2][1],ch->matrix.element[2][2]));
+ PICT_DEBUG_MSG(("transform matrix:\n"));
+ PICT_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[0][0], ch->matrix.element[0][1],ch->matrix.element[0][2]));
+ PICT_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[1][0], ch->matrix.element[1][1],ch->matrix.element[1][2]));
+ PICT_DEBUG_MSG(("%f %f %f\n", ch->matrix.element[2][0], ch->matrix.element[2][1],ch->matrix.element[2][2]));
}
void Pict2Parser::handlePolyline()
@@ -1414,9 +1414,9 @@ void Pict2Parser::handlePolyline()
}
}
- Pict_DEBUG_MSG((" Vertices count : %li\n", count));
+ PICT_DEBUG_MSG((" Vertices count : %li\n", count));
for(unsigned int j = 0; j < count; j++ )
- Pict_DEBUG_MSG((" Point #%d : %g,%g\n", j+1, points[j]["svg:x"]->getDouble(), points[j]["svg:x"]->getDouble()));
+ PICT_DEBUG_MSG((" Point #%d : %g,%g\n", j+1, points[j]["svg:x"]->getDouble(), points[j]["svg:x"]->getDouble()));
}
void Pict2Parser::handlePolyspline()
@@ -1550,12 +1550,12 @@ void Pict2Parser::handleRectangle()
m_painter->setStyle( tmpStyle, objCh.filled ? m_gradient : ::WPXPropertyListVector() );
m_painter->drawRectangle(propList);
- Pict_DEBUG_MSG((" X1 : %li\n", x1));
- Pict_DEBUG_MSG((" Y1 : %li\n", y1));
- Pict_DEBUG_MSG((" X2 : %li\n", x2));
- Pict_DEBUG_MSG((" Y2 : %li\n", y2));
- Pict_DEBUG_MSG((" Round X : %li\n", rx));
- Pict_DEBUG_MSG((" Round Y : %li\n", ry));
+ PICT_DEBUG_MSG((" X1 : %li\n", x1));
+ PICT_DEBUG_MSG((" Y1 : %li\n", y1));
+ PICT_DEBUG_MSG((" X2 : %li\n", x2));
+ PICT_DEBUG_MSG((" Y2 : %li\n", y2));
+ PICT_DEBUG_MSG((" Round X : %li\n", rx));
+ PICT_DEBUG_MSG((" Round Y : %li\n", ry));
}
void Pict2Parser::handleArc()
@@ -1628,14 +1628,14 @@ void Pict2Parser::handleArc()
m_painter->drawPath(path);
}
- Pict_DEBUG_MSG((" Center point x : %li\n", cx));
- Pict_DEBUG_MSG((" Center point y : %li\n", cy));
- Pict_DEBUG_MSG((" Radius x : %li\n", radx));
- Pict_DEBUG_MSG((" Radius y : %li\n", rady));
- Pict_DEBUG_MSG((" Initial point x : %li\n", ix));
- Pict_DEBUG_MSG((" Initial point y : %li\n", iy));
- Pict_DEBUG_MSG((" End point x : %li\n", ex));
- Pict_DEBUG_MSG((" End point y : %li\n", ey));
+ PICT_DEBUG_MSG((" Center point x : %li\n", cx));
+ PICT_DEBUG_MSG((" Center point y : %li\n", cy));
+ PICT_DEBUG_MSG((" Radius x : %li\n", radx));
+ PICT_DEBUG_MSG((" Radius y : %li\n", rady));
+ PICT_DEBUG_MSG((" Initial point x : %li\n", ix));
+ PICT_DEBUG_MSG((" Initial point y : %li\n", iy));
+ PICT_DEBUG_MSG((" End point x : %li\n", ex));
+ PICT_DEBUG_MSG((" End point y : %li\n", ey));
}
void Pict2Parser::handleBitmap()
@@ -1680,12 +1680,12 @@ void Pict2Parser::handleBitmap()
vres = 72;
m_bitmap.vres = vres;
- Pict_DEBUG_MSG((" x1 : %li\n", x1));
- Pict_DEBUG_MSG((" y1 : %li\n", y1));
- Pict_DEBUG_MSG((" x2 : %li\n", x2));
- Pict_DEBUG_MSG((" y2 : %li\n", y2));
- Pict_DEBUG_MSG((" hres : %li (pixel per inch)\n", hres));
- Pict_DEBUG_MSG((" vres : %li (pixel per inch)\n", vres));
+ PICT_DEBUG_MSG((" x1 : %li\n", x1));
+ PICT_DEBUG_MSG((" y1 : %li\n", y1));
+ PICT_DEBUG_MSG((" x2 : %li\n", x2));
+ PICT_DEBUG_MSG((" y2 : %li\n", y2));
+ PICT_DEBUG_MSG((" hres : %li (pixel per inch)\n", hres));
+ PICT_DEBUG_MSG((" vres : %li (pixel per inch)\n", vres));
}
void Pict2Parser::handleBitmapData()
@@ -1697,11 +1697,11 @@ void Pict2Parser::handleBitmapData()
unsigned color_format = readU8();
unsigned compression_format = readU8();
- Pict_DEBUG_MSG((" dimension : %g, %g %g, %g\n", m_bitmap.x1, m_bitmap.y1, m_bitmap.x2, m_bitmap.y2));
- Pict_DEBUG_MSG((" width : %i pixels\n", width));
- Pict_DEBUG_MSG((" height : %i pixels\n", height));
- Pict_DEBUG_MSG((" color format : %d\n", color_format));
- Pict_DEBUG_MSG((" compression : %d (%s)\n", compression_format,
+ PICT_DEBUG_MSG((" dimension : %g, %g %g, %g\n", m_bitmap.x1, m_bitmap.y1, m_bitmap.x2, m_bitmap.y2));
+ PICT_DEBUG_MSG((" width : %i pixels\n", width));
+ PICT_DEBUG_MSG((" height : %i pixels\n", height));
+ PICT_DEBUG_MSG((" color format : %d\n", color_format));
+ PICT_DEBUG_MSG((" compression : %d (%s)\n", compression_format,
(compression_format==0) ? "uncompressed":
(compression_format==1) ? "run-length encoding" : "unknown"));
@@ -1753,7 +1753,7 @@ void Pict2Parser::handleBitmapData()
unsigned next_scanline = 0;
unsigned data_size = 1;
- Pict_DEBUG_MSG(("Decoding RLE data\n"));
+ PICT_DEBUG_MSG(("Decoding RLE data\n"));
// FIXME check for ptr, it should not go out of bound!!
while (m_input->tell() <= m_recordEnd && !m_input->atEOS() && buffer.size() < tmpBufferSize)
@@ -1853,7 +1853,7 @@ void Pict2Parser::handleBitmapData()
// unreachable: only sentinel
else
{
- Pict_DEBUG_MSG((" ! unknown opcode %02x\n", opcode));
+ PICT_DEBUG_MSG((" ! unknown opcode %02x\n", opcode));
break;
}
@@ -1875,7 +1875,7 @@ void Pict2Parser::handleBitmapData()
}
- Pict_DEBUG_MSG(("Finish decoding RLE data\n"));
+ PICT_DEBUG_MSG(("Finish decoding RLE data\n"));
}
// no buffer? format is unknown
@@ -2116,11 +2116,11 @@ void Pict2Parser::handleObjectCapsule()
m_binaryData.objectIndex = 0;
- Pict_DEBUG_MSG((" x1 : %li\n", x1));
- Pict_DEBUG_MSG((" y1 : %li\n", y1));
- Pict_DEBUG_MSG((" x2 : %li\n", x2));
- Pict_DEBUG_MSG((" y2 : %li\n", y2));
- Pict_DEBUG_MSG(("numDescriptions : %li\n", numDescriptions));
+ PICT_DEBUG_MSG((" x1 : %li\n", x1));
+ PICT_DEBUG_MSG((" y1 : %li\n", y1));
+ PICT_DEBUG_MSG((" x2 : %li\n", x2));
+ PICT_DEBUG_MSG((" y2 : %li\n", y2));
+ PICT_DEBUG_MSG(("numDescriptions : %li\n", numDescriptions));
}
void Pict2Parser::handleObjectImage()
@@ -2139,12 +2139,12 @@ void Pict2Parser::handleObjectImage()
propList.insert("svg:height", (m_binaryData.y2 - m_binaryData.y1));
propList.insert("libpict:mime-type", m_binaryData.mimeTypes[m_binaryData.objectIndex]);
- Pict_DEBUG_MSG(("Image Object Mime Type : %s\n", propList["libpict:mime-type"]->getStr().cstr()));
+ PICT_DEBUG_MSG(("Image Object Mime Type : %s\n", propList["libpict:mime-type"]->getStr().cstr()));
::WPXBinaryData binaryData;
while (!m_input->atEOS() && m_input->tell() <= m_recordEnd)
binaryData.append((char)readU8());
- Pict_DEBUG_MSG((" Image Object Size : %li\n", (unsigned long)binaryData.size()));
+ PICT_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 DUMP_BINARY_DATA
@@ -2184,12 +2184,12 @@ void Pict2Parser::handleTextLine()
double baseLineAngle = fixedPointToDouble(readU32());
- Pict_DEBUG_MSG((" text flags : 0x%.4x\n", textFlags));
- Pict_DEBUG_MSG((" x : %li\n", x));
- Pict_DEBUG_MSG((" y : %li\n", y));
- Pict_DEBUG_MSG((" horizontal alignment : 0x%.2x\n", horizontalAlignment));
- Pict_DEBUG_MSG((" vertical alignment : 0x%.2x\n", verticalAlignment));
- Pict_DEBUG_MSG((" baseline angle : %.4f\n", baseLineAngle));
+ PICT_DEBUG_MSG((" text flags : 0x%.4x\n", textFlags));
+ PICT_DEBUG_MSG((" x : %li\n", x));
+ PICT_DEBUG_MSG((" y : %li\n", y));
+ PICT_DEBUG_MSG((" horizontal alignment : 0x%.2x\n", horizontalAlignment));
+ PICT_DEBUG_MSG((" vertical alignment : 0x%.2x\n", verticalAlignment));
+ PICT_DEBUG_MSG((" baseline angle : %.4f\n", baseLineAngle));
m_textData.x1 = TO_DOUBLE(x)/m_xres;
m_textData.y1 = TO_DOUBLE(y)/m_yres;
@@ -2223,10 +2223,10 @@ void Pict2Parser::handleTextBlock()
long ys1 = (y1 <= y2) ? y1 : y2;
long ys2 = (y1 <= y2) ? y2 : y1;
- Pict_DEBUG_MSG((" x1 : %li\n", xs1));
- Pict_DEBUG_MSG((" y1 : %li\n", ys1));
- Pict_DEBUG_MSG((" x2 : %li\n", xs2));
- Pict_DEBUG_MSG((" y2 : %li\n", ys2));
+ PICT_DEBUG_MSG((" x1 : %li\n", xs1));
+ PICT_DEBUG_MSG((" y1 : %li\n", ys1));
+ PICT_DEBUG_MSG((" x2 : %li\n", xs2));
+ PICT_DEBUG_MSG((" y2 : %li\n", ys2));
m_textData.x1 = TO_DOUBLE(xs1)/m_xres;
m_textData.y1 = TO_DOUBLE(ys1)/m_yres;
diff --git a/src/lib/PictBitmap.cpp b/src/lib/PictBitmap.cpp
index 3cf29e4..e16b0f1 100644
--- a/src/lib/PictBitmap.cpp
+++ b/src/lib/PictBitmap.cpp
@@ -178,7 +178,7 @@ const ::WPXBinaryData & libpict::PictBitmap::getDIB() const
writeU16(tmpDIBBuffer, tmpBufferPosition, 0); // Reserved2
writeU32(tmpDIBBuffer, tmpBufferPosition, tmpDIBOffsetBits); // OffsetBits
- Pict_DEBUG_MSG(("PictBitmap: DIB file header end = %i\n", tmpBufferPosition - 1));
+ PICT_DEBUG_MSG(("PictBitmap: DIB file header end = %i\n", tmpBufferPosition - 1));
// Create DIB Info header
writeU32(tmpDIBBuffer, tmpBufferPosition, 40); // Size
@@ -198,7 +198,7 @@ const ::WPXBinaryData & libpict::PictBitmap::getDIB() const
writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // ColorsUsed
writeU32(tmpDIBBuffer, tmpBufferPosition, 0); // ColorsImportant
- Pict_DEBUG_MSG(("PictBitmap: DIB info header end = %i\n", tmpBufferPosition - 1));
+ PICT_DEBUG_MSG(("PictBitmap: DIB info header end = %i\n", tmpBufferPosition - 1));
// Write DIB Image data
@@ -245,7 +245,7 @@ const ::WPXBinaryData & libpict::PictBitmap::getDIB() const
}
}
- Pict_DEBUG_MSG(("PictBitmap: DIB file size = %i\n", tmpBufferPosition - 1));
+ PICT_DEBUG_MSG(("PictBitmap: DIB file size = %i\n", tmpBufferPosition - 1));
#else
writeU8(tmpDIBBuffer, tmpBufferPosition, 0x7F);
diff --git a/src/lib/PictHeader.cpp b/src/lib/PictHeader.cpp
index a916e61..455fe10 100644
--- a/src/lib/PictHeader.cpp
+++ b/src/lib/PictHeader.cpp
@@ -29,16 +29,39 @@
namespace
{
-static inline unsigned short readU16( const void* p )
+unsigned char readU8(WPXInputStream *input)
{
- const unsigned char* ptr = (const unsigned char*) p;
- return (unsigned short)(ptr[0]+(ptr[1]<<8));
+ unsigned long numBytesRead;
+ unsigned char const *p = input->read(sizeof(unsigned char), numBytesRead);
+
+ if (numBytesRead != sizeof(unsigned char))
+ ;
+ PICT_DEBUG_MSG(("readU8: 0x%.2x\n",*(unsigned char const *)(p)));
+ return *(unsigned char const *)(p);
+}
+
+unsigned short readU16(WPXInputStream *input)
+{
+ unsigned long numBytesRead;
+ unsigned short const *p = (unsigned short const *)input->read(sizeof(unsigned short), numBytesRead);
+
+ if (numBytesRead != sizeof(unsigned short))
+ ;
+ unsigned short val = (unsigned short)((((unsigned char const *)(p))[1] << 0) | (((unsigned char const *)(p))[0] << 8));
+ PICT_DEBUG_MSG(("readU16: 0x%.4x\n", val));
+ return val;
}
-static inline unsigned long readU32( const void* p )
+unsigned readU32(WPXInputStream *input)
{
- const unsigned char* ptr = (const unsigned char*) p;
- return ptr[0]+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
+ unsigned long numBytesRead;
+ unsigned const *p = (unsigned int const *)input->read(sizeof(unsigned int), numBytesRead);
+ if (numBytesRead != sizeof(unsigned int))
+ ;
+ unsigned val = (unsigned)((((unsigned char const *)(p))[3] << 0) | (((unsigned char const *)(p))[2] << 8) |
+ (((unsigned char const *)(p))[1] << 16) | (((unsigned char const *)(p))[0] << 24));
+ PICT_DEBUG_MSG(("readU32: 0x%.8x\n", val));
+ return val;
}
}
@@ -47,34 +70,132 @@ PictHeader::PictHeader() :
m_xUpperLeftAt72(0),
m_yUpperLeftAt72(0),
m_xLowerRightAt72(0),
- m_yLoverRightAt72(0),
+ m_yLowerRightAt72(0),
m_pictVersion(0),
- m_resolutionX(72),
- m_resolutionY(72),
+ m_horizontalResolution(72),
+ m_verticalResolution(72),
+ m_pictureSize(0),
m_xUpperLeft(0),
m_yUpperLeft(0),
m_xLowerRight(0),
- m_yLowerRigth(0)
+ m_yLowerRight(0),
+ m_dataStart(0)
{
}
bool PictHeader::load(WPXInputStream *input)
{
- return false;
-}
-
-bool PictHeader::isSupported() const
-{
-
+ if (loadPict1Header(input))
+ return true;
+ if (loadPict2Header(input))
+ return true;
return false;
}
unsigned long PictHeader::startOfDocument() const
{
- return 0;
+ return m_dataStart;
}
int PictHeader::getVersion() const
{
return m_pictVersion;
}
+
+bool PictHeader::loadPict1Header(WPXInputStream *input)
+{
+ input->seek(0, WPX_SEEK_SET);
+ /* Try first to see whether the 512 bytes header is missing */
+ input->seek(10, WPX_SEEK_CUR);
+ if ((0x11 == readU8(input)) && (0x01 == readU8(input)))
+ input->seek(0, WPX_SEEK_CUR);
+ /* Ok, let us now skip the first 512 bytes and restart */
+ else {
+ input->seek(512 + 10, WPX_SEEK_SET);
+ if ((0x11 == readU8(input)) && (0x01 == readU8(input)))
+ input->seek(512, WPX_SEEK_SET);
+ else {
+ input->seek(0, WPX_SEEK_SET);
+ PICT_DEBUG_MSG(("No Pict1 header present\n"));
+ return false;
+ }
+ }
+ /* Now, we should be out or at the beginning of the Pict1 file */
+ PICT_DEBUG_MSG(("Reading Pict1 header\n"));
+ m_fileSize = readU16(input);
+ m_xUpperLeftAt72 = m_xUpperLeft = readU16(input);
+ m_yUpperLeftAt72 = m_yUpperLeft = readU16(input);
+ m_xLowerRightAt72 = m_xLowerRight = readU16(input);
+ m_yLowerRightAt72 = m_yLowerRight = readU16(input);
+ if (0x11 != readU8(input)) {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ if (0x01 != readU8(input)) {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ PICT_DEBUG_MSG(("Pict1Header: fileSize = 0x%.4x, upper left = (0x%.4x,0x%.4x), lower right = (0x%.4x,0x%.4x)\n", m_fileSize, m_xUpperLeft, m_yUpperLeft, m_xLowerRight, m_yLowerRight));
+ m_dataStart = input->tell();
+ input->seek(0, WPX_SEEK_SET);
+ return true;
+}
+
+bool PictHeader::loadPict2Header(WPXInputStream *input)
+{
+ input->seek(0, WPX_SEEK_SET);
+ /* Try first to see whether the 512 bytes header is missing */
+ input->seek(10, WPX_SEEK_CUR);
+ if ((0x0011 == readU16(input)) && (0x02FF == readU16(input)))
+ input->seek(0, WPX_SEEK_CUR);
+ /* Ok, let us now skip the first 512 bytes and restart */
+ else {
+ input->seek(512 + 10, WPX_SEEK_SET);
+ if ((0x0011 == readU16(input)) && (0x02FF == readU16(input)))
+ input->seek(512, WPX_SEEK_SET);
+ else {
+ input->seek(0, WPX_SEEK_SET);
+ PICT_DEBUG_MSG(("No Pict2 header present\n"));
+ return false;
+ }
+ }
+ /* Now, we should be out or at the beginning of the Pict1 file */
+ PICT_DEBUG_MSG(("Reading Pict2 header\n"));
+ m_fileSize = readU16(input);
+ m_xUpperLeftAt72 = readU16(input);
+ m_yUpperLeftAt72 = readU16(input);
+ m_xLowerRightAt72 = readU16(input);
+ m_yLowerRightAt72 = readU16(input);
+ if (0x0011 != readU16(input)) {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ if (0x02FF != readU16(input)) {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+ if (0x0C00 != readU16(input)) {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+#if 0
+ if (0xffee != (0xffee & readU16(input))) {
+ input->seek(0, WPX_SEEK_SET);
+ return false;
+ }
+#else
+ readU16(input);
+#endif
+ readU16(input); // reserved
+ m_horizontalResolution = readU32(input);
+ m_verticalResolution = readU32(input);
+ m_xUpperLeft = readU16(input);
+ m_yUpperLeft = readU16(input);
+ m_xLowerRight = readU16(input);
+ m_yLowerRight = readU16(input);
+ readU32(input); // reserved
+ PICT_DEBUG_MSG(("Pict2Header: fileSize = 0x%.4x, upper left = (0x%.4x,0x%.4x), lower right = (0x%.4x,0x%.4x)\n", m_fileSize, m_xUpperLeft, m_yUpperLeft, m_xLowerRight, m_yLowerRight));
+ m_dataStart = input->tell();
+ input->seek(0, WPX_SEEK_SET);
+ return true;
+}
diff --git a/src/lib/PictHeader.h b/src/lib/PictHeader.h
index 6ea4735..c9fc8da 100644
--- a/src/lib/PictHeader.h
+++ b/src/lib/PictHeader.h
@@ -35,8 +35,6 @@ public:
bool load(WPXInputStream *input);
- bool isSupported() const;
-
unsigned long startOfDocument() const;
int getVersion() const;
@@ -46,14 +44,16 @@ private:
unsigned short m_xUpperLeftAt72;
unsigned short m_yUpperLeftAt72;
unsigned short m_xLowerRightAt72;
- unsigned short m_yLoverRightAt72;
+ unsigned short m_yLowerRightAt72;
unsigned char m_pictVersion;
- unsigned long m_resolutionX;
- unsigned long m_resolutionY;
+ unsigned long m_horizontalResolution;
+ unsigned long m_verticalResolution;
+ unsigned long m_pictureSize;
unsigned short m_xUpperLeft;
unsigned short m_yUpperLeft;
unsigned short m_xLowerRight;
- unsigned short m_yLowerRigth;
+ unsigned short m_yLowerRight;
+ unsigned long m_dataStart;
bool loadPict1Header(WPXInputStream *input);
bool loadPict2Header(WPXInputStream *input);
diff --git a/src/lib/PictImage.cpp b/src/lib/PictImage.cpp
index 25d3410..f23a475 100644
--- a/src/lib/PictImage.cpp
+++ b/src/lib/PictImage.cpp
@@ -48,9 +48,7 @@ bool libpict::PictImage::isSupported(WPXInputStream* input)
if(!header.load(input))
return false;
- bool retVal = header.isSupported();
-
- return retVal;
+ return true;
}
/**
@@ -67,7 +65,7 @@ bool libpict::PictImage::parse(::WPXInputStream* input, libwpg::WPGPaintInterfac
input->seek(0, WPX_SEEK_SET);
- Pict_DEBUG_MSG(("Loading header...\n"));
+ PICT_DEBUG_MSG(("Loading header...\n"));
unsigned char tmpMajorVersion = 0x00;
if (fileFormat == Pict_Pict1)
tmpMajorVersion = 0x01;
@@ -77,49 +75,24 @@ bool libpict::PictImage::parse(::WPXInputStream* input, libwpg::WPGPaintInterfac
if(!header.load(input))
return false;
- if(!header.isSupported())
- {
- Pict_DEBUG_MSG(("Unsupported file format!\n"));
- return false;
- }
- else
- {
- // seek to the start of document
- input->seek(header.startOfDocument(), WPX_SEEK_SET);
- tmpMajorVersion = (unsigned char)(header.getVersion());
- if (tmpMajorVersion == 0x01)
- {
- unsigned long returnPosition = header.startOfDocument();
- /* Due to a bug in dumping mechanism, we produced
- * invalid Pict files by prepending a Pict1 header
- * to a valid WP file. Let us check this kind of files,
- * so that we can load our own mess too. */
- if (header.load(input) && header.isSupported())
- {
- Pict_DEBUG_MSG(("An invalid input we produced :(\n"));
- input->seek(header.startOfDocument() + 16, WPX_SEEK_SET);
- tmpMajorVersion = (unsigned char)(header.getVersion());
- }
- else
- input->seek(returnPosition, WPX_SEEK_SET);
-
- }
- }
+ // seek to the start of document
+ input->seek(header.startOfDocument(), WPX_SEEK_SET);
+ tmpMajorVersion = (unsigned char)(header.getVersion());
bool retval;
switch (tmpMajorVersion) {
case 0x01: // Pict1
- Pict_DEBUG_MSG(("Parsing Pict1\n"));
+ PICT_DEBUG_MSG(("Parsing Pict1\n"));
parser = new Pict1Parser(input, painter);
retval = parser->parse();
break;
case 0x02: // Pict2
- Pict_DEBUG_MSG(("Parsing Pict2\n"));
+ PICT_DEBUG_MSG(("Parsing Pict2\n"));
parser = new Pict2Parser(input, painter);
retval = parser->parse();
break;
default: // other :-)
- Pict_DEBUG_MSG(("Unknown format\n"));
+ PICT_DEBUG_MSG(("Unknown format\n"));
return false;
}
diff --git a/src/lib/PictXParser.cpp b/src/lib/PictXParser.cpp
index 0609cb9..1f137d1 100644
--- a/src/lib/PictXParser.cpp
+++ b/src/lib/PictXParser.cpp
@@ -110,7 +110,7 @@ PictXParser& PictXParser::operator=(const PictXParser& parser)
void PictTextDataHandler::endSubDocument()
{
- Pict_DEBUG_MSG(("PictTextDataHandler::endSubDocument\n"));
+ PICT_DEBUG_MSG(("PictTextDataHandler::endSubDocument\n"));
}
void PictTextDataHandler::openParagraph(const WPXPropertyList &propList, const WPXPropertyListVector & /* tabStops */)
@@ -135,7 +135,7 @@ void PictTextDataHandler::closeSpan()
void PictTextDataHandler::insertTab()
{
- Pict_DEBUG_MSG(("PictTextDataHandler::insertTab\n"));
+ PICT_DEBUG_MSG(("PictTextDataHandler::insertTab\n"));
}
void PictTextDataHandler::insertSpace()
@@ -150,7 +150,7 @@ void PictTextDataHandler::insertText(const WPXString &text)
void PictTextDataHandler::insertLineBreak()
{
- Pict_DEBUG_MSG(("PictTextDataHandler::insertLineBreak\n"));
+ PICT_DEBUG_MSG(("PictTextDataHandler::insertLineBreak\n"));
}
void PictTextDataHandler::openListElement(const WPXPropertyList & propList, const WPXPropertyListVector &/*tabStops*/)
@@ -160,5 +160,5 @@ void PictTextDataHandler::openListElement(const WPXPropertyList & propList, cons
void PictTextDataHandler::closeListElement()
{
- Pict_DEBUG_MSG(("PictTextDataHandler::closeListElement\n"));
+ PICT_DEBUG_MSG(("PictTextDataHandler::closeListElement\n"));
}
diff --git a/src/lib/libpict_utils.h b/src/lib/libpict_utils.h
index 7d83329..8a88201 100644
--- a/src/lib/libpict_utils.h
+++ b/src/lib/libpict_utils.h
@@ -36,14 +36,14 @@
// do nothing with debug messages in a release compile
#ifdef DEBUG
#ifdef VERBOSE_DEBUG
- #define Pict_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
+ #define PICT_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
#define Pict_DEBUG(M) M
#else
- #define Pict_DEBUG_MSG(M) printf M
+ #define PICT_DEBUG_MSG(M) printf M
#define Pict_DEBUG(M) M
#endif
#else
- #define Pict_DEBUG_MSG(M)
+ #define PICT_DEBUG_MSG(M)
#define Pict_DEBUG(M)
#endif