View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010355 | Scribus | Printing | public | 2011-11-01 11:35 | 2011-11-08 21:12 |
Reporter | wolneykien | Assigned To | jghali | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | x86-32 | OS | Linux | OS Version | ALT Linux p6 |
Product Version | 1.4.0svn | ||||
Fixed in Version | 1.4.0svn | ||||
Summary | 0010355: Reading of the PS part size and length from an EPSF is broken | ||||
Description | When printing a page with a linked EPSF image to a PS file from Scribus the EPSF contents are not included correctly if there is a preview header in the given EPSF. | ||||
Steps To Reproduce | Get an EPSF with a preview header (C5D0D3C6… as described in the http://partners.adobe.com/public/developer/en/ps/5002.EPSF_Spec.pdf). Open a new document. Place an image frame. Get the EPSF image into the frame. Print the document to the PS Level 3 file. Find the following-like lines in the output file: %%BeginDocument: <name-of-the-epsf>.eps ÅÐÓÆ^^ %%EndDocument As can be seen, only a few bytes of the EPSF are included. | ||||
Additional Information | The problem is in the PSLib::PS_image() function. The following patch fixes the reading of the EPSF PS size and length in the PS_image() function: get the double number via string conversion first, same way as it is done in the PS_ImageData() function. | ||||
Tags | No tags attached. | ||||
Patch | |||||
|
fix-epsf-printing-scribus.patch (1,179 bytes)
From 1feb0121c9f89097b4f7a3be86b172e65f5a5d94 Mon Sep 17 00:00:00 2001 From: Paul Wolneykien <manowar@altlinux.ru> Date: Tue, 1 Nov 2011 14:26:42 +0400 Subject: [PATCH] Fix the reading of the EPSF PS size and length Fix the reading of the EPSF PS size and length in the PS_image() function. Get the double number via string conversion first, same way as it is done in the PS_ImageData() function. --- scribus/scribus/pslib.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scribus/scribus/pslib.cpp b/scribus/scribus/pslib.cpp index e7ce466..5d71759 100644 --- a/scribus/scribus/pslib.cpp +++ b/scribus/scribus/pslib.cpp @@ -1531,8 +1531,8 @@ bool PSLib::PS_image(PageItem *c, double x, double y, QString fn, double scalex, if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6) { char* data = tmp.data(); - uint startPos = getDouble(tmp.mid(4, 4), false); - uint length = getDouble(tmp.mid(8, 4), false); + uint startPos = getDouble(QString(tmp.mid(4, 4)), false); + uint length = getDouble(QString(tmp.mid(8, 4)), false); PutStream(data+startPos, length, false); } else -- 1.7.3.3 |
|
Sorry, the patch above doen't resolve the problem. Debug session showed that getDouble() form scribus/util_math.cpp is passed an incorrect byte array. May be QString() introduces some errors. |
|
It seems that the problem is related to both QByteArray::insert() and the use of QString type as the intermediate representation of the data. First, the insert() method introduces spaces into the target array at the getDouble() function (scribus/util_math.cpp), so the number being parsed is corrupted. Second, an attempt to copy bytes to the target array from a string using QChar::cell() also results in a data corruption. So I decided not to use QString at all. Fixing the EPSF printing problem, the patch reveals the code branches I believe wasn't run for a while: for instance, the ScImgDataLoader_PS::parseData after a successful 0xC5D0D3C6 comparison. Note, other PS/EPS/printing isssues (0007958, 0005413, 0004468) may be related to the above problem and the solution. |
|
scribus-get-double.patch (4,844 bytes)
From 369cd803e1f18dddc0f27b226ed95aa6ff12f833 Mon Sep 17 00:00:00 2001 From: Paul Wolneykien <manowar@altlinux.ru> Date: Wed, 2 Nov 2011 05:48:14 +0400 Subject: [PATCH] Fix the reading of the PS part size and length from an EPS file Fix the getDouble() function and its calls. It seems that the problem is related to both QByteArray::insert() and the use of QString type as the intermediate representation of the data. First, the insert() method introduces spaces into the target array at the getDouble() function (scribus/util_math.cpp), so the number being parsed is corrupted. Second, an attempt to copy bytes to the target array from a string using QChar::cell() also results in a data corruption. So I decided not to use QString at all. --- scribus/scribus/pslib.cpp | 8 ++++---- scribus/scribus/scimgdataloader_ps.cpp | 2 +- scribus/scribus/util_math.cpp | 18 +++++++++--------- scribus/scribus/util_math.h | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scribus/scribus/pslib.cpp b/scribus/scribus/pslib.cpp index e7ce466..6d3f8f8 100644 --- a/scribus/scribus/pslib.cpp +++ b/scribus/scribus/pslib.cpp @@ -1443,11 +1443,11 @@ bool PSLib::PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bo { PutStream("currentfile 1 (%ENDEPSDATA) /SubFileDecode filter /ReusableStreamDecode filter\n"); PutStream("%%BeginDocument: " + fi.fileName() + "\n"); - if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6) + if (getDouble(tmp.mid(0, 4), true) == 0xC5D0D3C6) { char* data = tmp.data(); - uint startPos = getDouble(QString(tmp.mid(4, 4)), false); - uint length = getDouble(QString(tmp.mid(8, 4)), false); + uint startPos = getDouble(tmp.mid(4, 4), false); + uint length = getDouble(tmp.mid(8, 4), false); PutStream(data+startPos, length, false); } else @@ -1528,7 +1528,7 @@ bool PSLib::PS_image(PageItem *c, double x, double y, QString fn, double scalex, else { PutStream("%%BeginDocument: " + fi.fileName() + "\n"); - if (getDouble(QString(tmp.mid(0, 4)), true) == 0xC5D0D3C6) + if (getDouble(tmp.mid(0, 4), true) == 0xC5D0D3C6) { char* data = tmp.data(); uint startPos = getDouble(tmp.mid(4, 4), false); diff --git a/scribus/scribus/scimgdataloader_ps.cpp b/scribus/scribus/scimgdataloader_ps.cpp index 3c03b9f..4e0c8f3 100644 --- a/scribus/scribus/scimgdataloader_ps.cpp +++ b/scribus/scribus/scimgdataloader_ps.cpp @@ -147,7 +147,7 @@ bool ScImgDataLoader_PS::parseData(QString fn) { QByteArray tempBuf(9, ' '); f.read(tempBuf.data(), 8); - if (getDouble(QString(tempBuf.mid(0, 4)), true) == 0xC5D0D3C6) + if (getDouble(tempBuf.mid(0, 4), true) == 0xC5D0D3C6) { startPos = getDouble(tempBuf.mid(4, 4), false); if (doThumbnail) diff --git a/scribus/scribus/util_math.cpp b/scribus/scribus/util_math.cpp index e398616..8736b36 100644 --- a/scribus/scribus/util_math.cpp +++ b/scribus/scribus/util_math.cpp @@ -30,7 +30,7 @@ using namespace std; -uint getDouble(QString in, bool raw) +uint getDouble(QByteArray in, bool raw) { QByteArray bb(4, ' '); if (raw) @@ -40,10 +40,10 @@ uint getDouble(QString in, bool raw) bb[2] = static_cast<uchar>(QChar(in.at(1))); bb[1] = static_cast<uchar>(QChar(in.at(2))); bb[0] = static_cast<uchar>(QChar(in.at(3)));*/ - bb = bb.insert(3, in.at(0)); - bb = bb.insert(2, in.at(1)); - bb = bb.insert(1, in.at(2)); - bb = bb.insert(0, in.at(3)); + bb[3] = in[0]; + bb[2] = in[1]; + bb[1] = in[2]; + bb[0] = in[3]; } else { @@ -52,10 +52,10 @@ uint getDouble(QString in, bool raw) // bb[1] = static_cast<uchar>(QChar(in.at(1))); // bb[2] = static_cast<uchar>(QChar(in.at(2))); // bb[3] = static_cast<uchar>(QChar(in.at(3))); - bb = bb.insert(0, in.at(0)); - bb = bb.insert(1, in.at(1)); - bb = bb.insert(2, in.at(2)); - bb = bb.insert(3, in.at(3)); + bb[0] = in[0]; + bb[1] = in[1]; + bb[2] = in[2]; + bb[3] = in[3]; } uint ret; ret = bb[0] & 0xff; diff --git a/scribus/scribus/util_math.h b/scribus/scribus/util_math.h index 603495c..688444d 100644 --- a/scribus/scribus/util_math.h +++ b/scribus/scribus/util_math.h @@ -35,7 +35,7 @@ FPoint SCRIBUS_API projectPointOnLine(FPoint p, QPointF lineStart, QPointF lineE QPolygon SCRIBUS_API FlattenPath(const FPointArray& ina, QList<uint> &Segs); QList<QPainterPath> SCRIBUS_API decomposePath(QPainterPath &path); QPainterPath SCRIBUS_API RegularPolygon(double w, double h, uint c, bool star, double factor, double rota, double factor2 = 0.0); -uint SCRIBUS_API getDouble(QString in, bool raw); +uint SCRIBUS_API getDouble(QByteArray in, bool raw); inline double SCRIBUS_API sind(double); inline double SCRIBUS_API cosd(double); inline double SCRIBUS_API square(double); -- 1.7.3.3 |
|
The uploaded scribus-get-double.patch fixes the problem. |
|
Thanks, the issue is now indeed fixed. |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-11-01 11:35 | wolneykien | New Issue | |
2011-11-01 11:35 | wolneykien | File Added: fix-epsf-printing-scribus.patch | |
2011-11-01 21:12 | wolneykien | Note Added: 0027146 | |
2011-11-02 01:44 | wolneykien | Note Added: 0027151 | |
2011-11-02 02:13 | wolneykien | File Added: scribus-get-double.patch | |
2011-11-02 02:14 | wolneykien | Note Added: 0027152 | |
2011-11-05 01:33 | jghali | Note Added: 0027162 | |
2011-11-05 01:33 | jghali | Status | new => resolved |
2011-11-05 01:33 | jghali | Fixed in Version | => 1.4.0svn |
2011-11-05 01:33 | jghali | Resolution | open => fixed |
2011-11-05 01:33 | jghali | Assigned To | => jghali |
2011-11-08 21:12 | cbradney | Status | resolved => closed |