r20125 by fschmid - PDF Import: import masked images correctly.
scribus-commit
scribus-commit at lists.scribus.net
Sun May 24 08:19:56 UTC 2015
Author: fschmid
Date: Sun May 24 08:19:56 2015
New Revision: 20125
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20125
Log:
PDF Import: import masked images correctly.
Modified:
trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20125&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Sun May 24 08:19:56 2015
@@ -18,6 +18,7 @@
#include "slaoutput.h"
#include <poppler/ErrorCodes.h>
#include <poppler/GlobalParams.h>
+#include <poppler/OptionalContent.h>
#include <poppler/PageTransition.h>
#include <poppler/ViewerPreferences.h>
#include <poppler/poppler-config.h>
@@ -441,7 +442,7 @@
int firstPage = 1;
int lastPage = pdfDoc->getNumPages();
GBool useMediaBox = gTrue;
- GBool crop = gFalse;
+ GBool crop = gTrue;
GBool printing = gFalse;
PDFRectangle *mediaBox = pdfDoc->getPage(1)->getMediaBox();
QRectF mediaRect = QRectF(QPointF(mediaBox->x1, mediaBox->y1), QPointF(mediaBox->x2, mediaBox->y2)).normalized();
@@ -474,12 +475,17 @@
return false;
}
pageString = optImp->getPagesString();
- int cb = optImp->getCropBox();
- if (cb > Media_Box)
+ contentRect = optImp->getCropBox();
+ cropped = optImp->croppingEnabled();
+ if (!cropped)
+ crop = cropped;
+ if (contentRect != Media_Box)
+ useMediaBox = gFalse;
+ /* if (cb > Media_Box)
{
cropped = true;
contentRect = cb;
- }
+ } */
delete optImp;
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
if (progressDialog)
@@ -578,7 +584,9 @@
currentLayer = m_Doc->addLayer(UnicodeParsedString(oc->getName()), false);
else
currentLayer = m_Doc->layerIDFromName(UnicodeParsedString(oc->getName()));
- if ((oc->getViewState() == OptionalContentGroup::ocUsageOn) || (oc->getViewState() == OptionalContentGroup::ocUsageUnset))
+ if (oc->getState() == OptionalContentGroup::On)
+ m_Doc->setLayerVisible(currentLayer, true);
+ else if (oc->getViewState() == OptionalContentGroup::ocUsageOn)
m_Doc->setLayerVisible(currentLayer, true);
else
m_Doc->setLayerVisible(currentLayer, false);
@@ -705,24 +713,36 @@
m_Doc->reformPages(true);
if (hasOcg)
{
+ // int numObj = m_Doc->Items->count();
+ // if (cropped)
+ // pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x(), crBox.y(), crBox.width(), crBox.height(), NULL, NULL, dev->annotations_callback, dev);
+ // else
+ // pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, NULL, NULL, dev->annotations_callback, dev);
+ // int numObj2 = m_Doc->Items->count();
+ // int countObj = numObj2 - numObj;
for (int a = 0; a < ocgGroups.count(); a++)
{
OptionalContentGroup *oc = ocgGroups[a];
- // m_Doc->setActiveLayer(UnicodeParsedString(oc->getName()));
- // currentLayer = m_Doc->activeLayer();
+ // m_Doc->setActiveLayer(UnicodeParsedString(oc->getName()));
+ // currentLayer = m_Doc->activeLayer();
oc->setState(OptionalContentGroup::On);
- // pdfDoc->displayPage(dev, pp + 1, hDPI, vDPI, rotate, useMediaBox, crop, printing);
- // oc->setState(OptionalContentGroup::Off);
+ if (cropped)
+ pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x(), mediaRect.bottom() - crBox.bottom(), crBox.width(), crBox.height(), NULL, NULL, dev->annotations_callback, dev);
+ else
+ pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, NULL, NULL, dev->annotations_callback, dev);
+ oc->setState(OptionalContentGroup::Off);
+ // for (int dd = 0; dd < countObj; dd++)
+ // {
+ // PageItem *iteD = m_Doc->Items->takeAt(numObj2);
+ // delete iteD;
+ // }
+ // numObj2 = m_Doc->Items->count();
}
+ }
+ else
+ {
if (cropped)
- pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x(), crBox.y(), crBox.width(), crBox.height(), NULL, NULL, dev->annotations_callback, dev);
- else
- pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, NULL, NULL, dev->annotations_callback, dev);
- }
- else
- {
- if (cropped)
- pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x(), crBox.y(), crBox.width(), crBox.height(), NULL, NULL, dev->annotations_callback, dev);
+ pdfDoc->displayPageSlice(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, crBox.x(), mediaRect.bottom() - crBox.bottom(), crBox.width(), crBox.height(), NULL, NULL, dev->annotations_callback, dev);
else
pdfDoc->displayPage(dev, pp, hDPI, vDPI, rotate, useMediaBox, crop, printing, NULL, NULL, dev->annotations_callback, dev);
}
Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20125&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.cpp Sun May 24 08:19:56 2015
@@ -54,6 +54,11 @@
if (ui->cropGroup->isChecked())
ret = ui->cropBox->currentIndex();
return ret;
+}
+
+bool PdfImportOptions::croppingEnabled()
+{
+ return ui->cropGroup->isChecked();
}
void PdfImportOptions::setUpOptions(QString fileName, int actPage, int numPages, bool interact, bool cropPossible, PdfPlug* plug)
Modified: trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20125&path=/trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/pdfimportoptions.h Sun May 24 08:19:56 2015
@@ -24,6 +24,7 @@
void setUpOptions(QString fileName, int actPage, int numPages, bool interact, bool cropPossible, PdfPlug* plug);
QString getPagesString();
int getCropBox();
+ bool croppingEnabled();
void paintEvent(QPaintEvent *e);
protected:
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20125&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Sun May 24 08:19:56 2015
@@ -1284,6 +1284,7 @@
ite->PoLine = out.copy();
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_doc->AdjustItemSize(ite, true);
+ m_doc->resizeGroupToContents(ite);
ite->OldB2 = ite->width();
ite->OldH2 = ite->height();
m_Elements->append(ite);
@@ -1315,6 +1316,7 @@
void SlaOutputDev::beginTransparencyGroup(GfxState *state, double *bbox, GfxColorSpace * /*blendingColorSpace*/, GBool isolated, GBool knockout, GBool forSoftMask)
{
pushGroup("", forSoftMask);
+ m_groupStack.top().isolated = isolated;
}
void SlaOutputDev::paintTransparencyGroup(GfxState *state, double *bbox)
@@ -1376,7 +1378,7 @@
tmpSel->addItem(gElements.Items.at(dre), true);
m_Elements->removeAll(gElements.Items.at(dre));
}
- if (gElements.Items.count() != 1)
+ if ((gElements.Items.count() != 1) || (gElements.isolated))
ite = m_doc->groupObjectsSelection(tmpSel);
else
ite = gElements.Items.first();
@@ -1392,6 +1394,7 @@
ite->PoLine = out.copy();
ite->setTextFlowMode(PageItem::TextFlowDisabled);
m_doc->AdjustItemSize(ite, true);
+ m_doc->resizeGroupToContents(ite);
ite->OldB2 = ite->width();
ite->OldH2 = ite->height();
}
@@ -1957,13 +1960,6 @@
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None, true);
PageItem* ite = m_doc->Items->at(z);
- if (checkClip())
- {
- FPointArray out = m_currentClipPath.copy();
- FPoint wh(getMinClipF(&out));
- out.translate(-wh.x(), -wh.y());
- ite->PoLine = out.copy();
- }
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(CurrFillShade);
@@ -2045,13 +2041,6 @@
m_ctm = QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5]);
int z = m_doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, xCoor + crect.x(), yCoor + crect.y(), crect.width(), crect.height(), 0, CurrColorFill, CommonStrings::None, true);
PageItem* ite = m_doc->Items->at(z);
- if (checkClip())
- {
- FPointArray out = m_currentClipPath.copy();
- FPoint wh(getMinClipF(&out));
- out.translate(-wh.x(), -wh.y());
- ite->PoLine = out.copy();
- }
ite->ClipEdited = true;
ite->FrameType = 3;
ite->setFillShade(CurrFillShade);
@@ -2069,7 +2058,6 @@
m_groupStack.top().Items.append(ite);
applyMask(ite);
}
-// qDebug() << "Mesh of" << shading->getNPatches() << "Patches";
ite->meshGradientPatches.clear();
for (int i = 0; i < shading->getNPatches(); i++)
{
@@ -2501,14 +2489,7 @@
maskColorMap->getGrayLine(pix, mdest, maskWidth);
}
if ((maskWidth != width) || (maskHeight != height))
- {
- delete imgStr;
- delete[] buffer;
- delete image;
- delete mskStr;
- delete[] mbuffer;
- return;
- }
+ *image = image->scaled(maskWidth, maskHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QImage res = image->convertToFormat(QImage::Format_ARGB32);
unsigned char cc, cm, cy, ck;
int s = 0;
@@ -2655,14 +2636,7 @@
}
}
if ((maskWidth != width) || (maskHeight != height))
- {
- delete imgStr;
- delete[] buffer;
- delete image;
- delete mskStr;
- delete[] mbuffer;
- return;
- }
+ *image = image->scaled(maskWidth, maskHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
QImage res = image->convertToFormat(QImage::Format_ARGB32);
unsigned char cc, cm, cy, ck;
int s = 0;
Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20125&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.h Sun May 24 08:19:56 2015
@@ -164,6 +164,7 @@
virtual GBool useShadedFills(int type) { return type <= 7; }
virtual GBool useFillColorStop() { return gTrue; }
virtual GBool useDrawForm() { return gFalse; }
+// virtual GBool needClipToCropBox() { return gTrue; }
virtual void startPage(int pageNum, GfxState *, XRef *);
virtual void endPage();
// grapics state
@@ -175,6 +176,7 @@
virtual void fill(GfxState *state);
virtual void eoFill(GfxState *state);
GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, double *pmat, int paintType, int tilingType, Dict *resDict, double *mat, double *bbox, int x0, int y0, int x1, int y1, double xStep, double yStep);
+ virtual GBool functionShadedFill(GfxState * /*state*/, GfxFunctionShading * /*shading*/) { qDebug() << "Function Shaded Fill"; return gFalse; }
virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
virtual GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) { return (shading->getExtend0() == shading->getExtend1()); }
virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax);
@@ -282,6 +284,7 @@
{
QList<PageItem*> Items;
GBool forSoftMask;
+ GBool isolated;
GBool alpha;
QString maskName;
bool inverted;
More information about the scribus-commit
mailing list