r19110 by fschmid - Fixed Bug #9687: exporting to PNG with transparent background
scribus-commit
scribus-commit at lists.scribus.net
Sun May 11 08:10:55 UTC 2014
Author: fschmid
Date: Sun May 11 08:10:55 2014
New Revision: 19110
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19110
Log:
Fixed Bug #9687: exporting to PNG with transparent background
Modified:
trunk/Scribus/scribus/plugins/export/pixmapexport/dialog.cpp
trunk/Scribus/scribus/plugins/export/pixmapexport/export.cpp
trunk/Scribus/scribus/plugins/export/pixmapexport/export.h
trunk/Scribus/scribus/plugins/export/pixmapexport/exportform.ui
trunk/Scribus/scribus/scribusview.cpp
trunk/Scribus/scribus/scribusview.h
Modified: trunk/Scribus/scribus/plugins/export/pixmapexport/dialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19110&path=/trunk/Scribus/scribus/plugins/export/pixmapexport/dialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/pixmapexport/dialog.cpp (original)
+++ trunk/Scribus/scribus/plugins/export/pixmapexport/dialog.cpp Sun May 11 08:10:55 2014
@@ -49,6 +49,7 @@
pageNrButton->setIcon(loadIcon("ellipsis.png"));
rangeVal->setEnabled(false);
pageNrButton->setEnabled(false);
+ noBackground->setChecked(false);
languageChange();
readConfig();
@@ -125,6 +126,7 @@
bitmapType->setToolTip( tr( "Available export formats" ) );
outputDirectory->setToolTip( tr( "The output directory - the place to store your images.\nName of the export file will be 'documentname-pagenumber.filetype'" ) );
outputDirectoryButton->setToolTip( tr( "Change the output directory" ) );
+ noBackground->setToolTip( tr("Don't export Page Background"));
}
Modified: trunk/Scribus/scribus/plugins/export/pixmapexport/export.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19110&path=/trunk/Scribus/scribus/plugins/export/pixmapexport/export.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/pixmapexport/export.cpp (original)
+++ trunk/Scribus/scribus/plugins/export/pixmapexport/export.cpp Sun May 11 08:10:55 2014
@@ -133,14 +133,14 @@
doc->scMW()->mainWindowProgressBar->reset();
bool res;
if (dia->onePageRadio->isChecked())
- res = ex->exportCurrent(doc);
+ res = ex->exportCurrent(doc, !dia->noBackground->isChecked());
else
{
if (dia->allPagesRadio->isChecked())
parsePagesString("*", &pageNs, doc->DocPages.count());
else
parsePagesString(dia->rangeVal->text(), &pageNs, doc->DocPages.count());
- res = ex->exportInterval(doc, pageNs);
+ res = ex->exportInterval(doc, pageNs, !dia->noBackground->isChecked());
}
doc->scMW()->mainWindowProgressBar->reset();
QApplication::changeOverrideCursor(Qt::ArrowCursor);
@@ -171,7 +171,7 @@
{
}
-bool ExportBitmap::exportPage(ScribusDoc* doc, uint pageNr, bool single = true)
+bool ExportBitmap::exportPage(ScribusDoc* doc, uint pageNr, bool background, bool single = true)
{
uint over = 0;
bool saved = false, doFileSave = true;
@@ -186,7 +186,7 @@
* portrait and user defined sizes.
*/
double pixmapSize = (page->height() > page->width()) ? page->height() : page->width();
- QImage im(doc->view()->PageToPixmap(pageNr, qRound(pixmapSize * enlargement * (pageDPI / 72.0) / 100.0), false));
+ QImage im(doc->view()->PageToPixmap(pageNr, qRound(pixmapSize * enlargement * (pageDPI / 72.0) / 100.0), false, background));
if (im.isNull())
{
QMessageBox::warning(doc->scMW(), tr("Save as Image"), tr("Insufficient memory for this image size."));
@@ -222,18 +222,18 @@
return saved;
}
-bool ExportBitmap::exportCurrent(ScribusDoc* doc)
-{
- return exportPage(doc, doc->currentPageNumber(), true);
-}
-
-bool ExportBitmap::exportInterval(ScribusDoc* doc, std::vector<int> &pageNs)
+bool ExportBitmap::exportCurrent(ScribusDoc* doc, bool background)
+{
+ return exportPage(doc, doc->currentPageNumber(), background, true);
+}
+
+bool ExportBitmap::exportInterval(ScribusDoc* doc, std::vector<int> &pageNs, bool background)
{
doc->scMW()->mainWindowProgressBar->setMaximum(pageNs.size());
for (uint a = 0; a < pageNs.size(); ++a)
{
doc->scMW()->mainWindowProgressBar->setValue(a);
- if (!exportPage(doc, pageNs[a]-1, false))
+ if (!exportPage(doc, pageNs[a]-1, background, false))
return false;
}
return true;
Modified: trunk/Scribus/scribus/plugins/export/pixmapexport/export.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19110&path=/trunk/Scribus/scribus/plugins/export/pixmapexport/export.h
==============================================================================
--- trunk/Scribus/scribus/plugins/export/pixmapexport/export.h (original)
+++ trunk/Scribus/scribus/plugins/export/pixmapexport/export.h Sun May 11 08:10:55 2014
@@ -64,11 +64,11 @@
/*! \brief Exports only the actual page
\retval bool true on success */
- bool exportCurrent(ScribusDoc* doc);
+ bool exportCurrent(ScribusDoc* doc, bool background);
/*! \brief Exports chosen interval of the pages
\param pageNs interval of the page numbers
\retval true on success */
- bool exportInterval(ScribusDoc* doc, std::vector<int> &pageNs);
+ bool exportInterval(ScribusDoc* doc, std::vector<int> &pageNs, bool background);
private:
/*! \brief create specified filename "docfilename-005.ext" */
QString getFileName(ScribusDoc* doc, uint pageNr);
@@ -77,7 +77,7 @@
\param single bool TRUE if only the one page is exported
\retval bool true on success
*/
- bool exportPage(ScribusDoc* doc, uint pageNr, bool single);
+ bool exportPage(ScribusDoc* doc, uint pageNr, bool background, bool single);
};
#endif
Modified: trunk/Scribus/scribus/plugins/export/pixmapexport/exportform.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19110&path=/trunk/Scribus/scribus/plugins/export/pixmapexport/exportform.ui
==============================================================================
--- trunk/Scribus/scribus/plugins/export/pixmapexport/exportform.ui (original)
+++ trunk/Scribus/scribus/plugins/export/pixmapexport/exportform.ui Sun May 11 08:10:55 2014
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>ExportForm</class>
- <widget class="QDialog" name="ExportForm" >
- <property name="geometry" >
+ <widget class="QDialog" name="ExportForm">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@@ -9,201 +10,229 @@
<height>339</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>Export as Image(s)</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout">
+ <property name="leftMargin">
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="topMargin">
+ <number>9</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <property name="bottomMargin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
<number>6</number>
</property>
- <item row="1" column="0" >
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
<string>Options</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="5" column="0" colspan="2" >
- <widget class="QLabel" name="imageSizeLabel" >
- <property name="text" >
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Image &Type:</string>
+ </property>
+ <property name="buddy">
+ <cstring>bitmapType</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="bitmapType"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>&Quality:</string>
+ </property>
+ <property name="buddy">
+ <cstring>qualityBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="qualityBox">
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>&Resolution:</string>
+ </property>
+ <property name="buddy">
+ <cstring>DPIBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="DPIBox">
+ <property name="suffix">
+ <string> dpi</string>
+ </property>
+ <property name="minimum">
+ <number>72</number>
+ </property>
+ <property name="maximum">
+ <number>2400</number>
+ </property>
+ <property name="value">
+ <number>72</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>&Size:</string>
+ </property>
+ <property name="buddy">
+ <cstring>enlargementBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="enlargementBox">
+ <property name="suffix">
+ <string> %</string>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>2400</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <widget class="QCheckBox" name="noBackground">
+ <property name="text">
+ <string>No Background</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Image size in Pixels</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="imageSizeLabel">
+ <property name="text">
<string>TextLabel</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0" colspan="2" >
- <widget class="QLabel" name="label_6" >
- <property name="text" >
- <string>Image size in Pixels</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QComboBox" name="bitmapType" />
- </item>
- <item row="0" column="0" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>Image &Type:</string>
- </property>
- <property name="buddy" >
- <cstring>bitmapType</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QLabel" name="label_3" >
- <property name="text" >
- <string>&Quality:</string>
- </property>
- <property name="buddy" >
- <cstring>qualityBox</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QLabel" name="label_4" >
- <property name="text" >
- <string>&Resolution:</string>
- </property>
- <property name="buddy" >
- <cstring>DPIBox</cstring>
- </property>
- </widget>
- </item>
- <item row="3" column="0" >
- <widget class="QLabel" name="label_5" >
- <property name="text" >
- <string>&Size:</string>
- </property>
- <property name="buddy" >
- <cstring>enlargementBox</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QSpinBox" name="qualityBox" >
- <property name="suffix" >
- <string> %</string>
- </property>
- <property name="maximum" >
- <number>100</number>
- </property>
- <property name="minimum" >
- <number>-1</number>
- </property>
- <property name="value" >
- <number>-1</number>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QSpinBox" name="DPIBox" >
- <property name="suffix" >
- <string> dpi</string>
- </property>
- <property name="maximum" >
- <number>2400</number>
- </property>
- <property name="minimum" >
- <number>72</number>
- </property>
- <property name="value" >
- <number>72</number>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="QSpinBox" name="enlargementBox" >
- <property name="suffix" >
- <string> %</string>
- </property>
- <property name="maximum" >
- <number>2400</number>
- </property>
- <property name="minimum" >
- <number>1</number>
- </property>
- <property name="value" >
- <number>100</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
- <item row="0" column="0" colspan="2" >
- <layout class="QHBoxLayout" >
- <property name="margin" >
+ <item row="0" column="0" colspan="2">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="leftMargin">
<number>0</number>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
</property>
<item>
- <widget class="QLabel" name="label" >
- <property name="text" >
+ <widget class="QLabel" name="label">
+ <property name="text">
<string>&Export to Directory:</string>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>outputDirectory</cstring>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="outputDirectory" />
+ <widget class="QLineEdit" name="outputDirectory"/>
</item>
<item>
- <widget class="QPushButton" name="outputDirectoryButton" >
- <property name="text" >
+ <widget class="QPushButton" name="outputDirectoryButton">
+ <property name="text">
<string>C&hange...</string>
</property>
</widget>
</item>
</layout>
</item>
- <item row="1" column="1" >
- <widget class="QGroupBox" name="rangeGroupBox" >
- <property name="title" >
+ <item row="1" column="1">
+ <widget class="QGroupBox" name="rangeGroupBox">
+ <property name="title">
<string>Range</string>
</property>
- <layout class="QGridLayout" >
- <property name="margin" >
+ <layout class="QGridLayout">
+ <property name="leftMargin">
<number>9</number>
</property>
- <property name="spacing" >
+ <property name="topMargin">
+ <number>9</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <property name="bottomMargin">
+ <number>9</number>
+ </property>
+ <property name="spacing">
<number>6</number>
</property>
- <item row="2" column="2" >
- <widget class="QPushButton" name="pageNrButton" >
- <property name="text" >
+ <item row="2" column="2">
+ <widget class="QPushButton" name="pageNrButton">
+ <property name="text">
<string/>
</property>
</widget>
</item>
- <item row="2" column="1" >
- <widget class="QLineEdit" name="rangeVal" />
- </item>
- <item row="0" column="0" colspan="3" >
- <widget class="QRadioButton" name="onePageRadio" >
- <property name="text" >
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="rangeVal"/>
+ </item>
+ <item row="0" column="0" colspan="3">
+ <widget class="QRadioButton" name="onePageRadio">
+ <property name="text">
<string>&Current page</string>
</property>
</widget>
</item>
- <item row="3" column="0" >
+ <item row="3" column="0">
<spacer>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" >
+ <property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
@@ -211,16 +240,16 @@
</property>
</spacer>
</item>
- <item row="2" column="0" >
- <widget class="QRadioButton" name="intervalPagesRadio" >
- <property name="text" >
+ <item row="2" column="0">
+ <widget class="QRadioButton" name="intervalPagesRadio">
+ <property name="text">
<string>&Range</string>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QRadioButton" name="allPagesRadio" >
- <property name="text" >
+ <item row="1" column="0">
+ <widget class="QRadioButton" name="allPagesRadio">
+ <property name="text">
<string>&All pages</string>
</property>
</widget>
@@ -228,13 +257,13 @@
</layout>
</widget>
</item>
- <item row="2" column="0" colspan="2" >
- <widget class="QDialogButtonBox" name="buttonBox" >
- <property name="orientation" >
+ <item row="2" column="0" colspan="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="standardButtons" >
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@@ -248,11 +277,11 @@
<receiver>ExportForm</receiver>
<slot>accept()</slot>
<hints>
- <hint type="sourcelabel" >
+ <hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
- <hint type="destinationlabel" >
+ <hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
@@ -264,11 +293,11 @@
<receiver>ExportForm</receiver>
<slot>reject()</slot>
<hints>
- <hint type="sourcelabel" >
+ <hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
- <hint type="destinationlabel" >
+ <hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19110&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Sun May 11 08:10:55 2014
@@ -2555,7 +2555,7 @@
return im;
}
-QImage ScribusView::PageToPixmap(int Nr, int maxGr, bool drawFrame)
+QImage ScribusView::PageToPixmap(int Nr, int maxGr, bool drawFrame, bool drawBackground)
{
QImage im;
double sx = maxGr / Doc->DocPages.at(Nr)->width();
@@ -2570,6 +2570,7 @@
im = QImage(clipw, cliph, QImage::Format_ARGB32_Premultiplied);
if (!im.isNull())
{
+ im.fill( qRgba(0, 0, 0, 0) );
double oldScale = m_canvas->scale();
double cx = Doc->minCanvasCoordinate.x();
double cy = Doc->minCanvasCoordinate.y();
@@ -2596,7 +2597,8 @@
Doc->setLoading(true);
Doc->setCurrentPage(Doc->DocPages.at(Nr));
ScPainter *painter = new ScPainter(&im, im.width(), im.height(), 1.0, 0);
- painter->clear(Doc->paperColor());
+ if (drawBackground)
+ painter->clear(Doc->paperColor());
painter->translate(-clipx, -clipy);
painter->setFillMode(ScPainter::Solid);
if (drawFrame)
Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19110&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Sun May 11 08:10:55 2014
@@ -166,7 +166,7 @@
void hideSymbolPage();
void showInlinePage(int id);
void hideInlinePage();
- QImage PageToPixmap(int Nr, int maxGr, bool drawFrame = true);
+ QImage PageToPixmap(int Nr, int maxGr, bool drawFrame = true, bool drawBackground = true);
QImage MPageToPixmap(QString name, int maxGr, bool drawFrame = true);
void RecalcPicturesRes();
/**
More information about the scribus-commit
mailing list