r22742 by jghali - #15455: Add transparency to image exporter in scripter <Gibbz>
scribus-commit
scribus-commit at lists.scribus.net
Wed Oct 31 23:30:43 UTC 2018
Author: jghali
Date: Wed Oct 31 23:30:43 2018
New Revision: 22742
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22742
Log:
#15455: Add transparency to image exporter in scripter <Gibbz>
Modified:
trunk/Scribus/doc/en/scripterapi-ImageExport.html
trunk/Scribus/doc/fr/scripterapi-ImageExport.html
trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp
trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.h
Modified: trunk/Scribus/doc/en/scripterapi-ImageExport.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22742&path=/trunk/Scribus/doc/en/scripterapi-ImageExport.html
==============================================================================
--- trunk/Scribus/doc/en/scripterapi-ImageExport.html (original)
+++ trunk/Scribus/doc/en/scripterapi-ImageExport.html Wed Oct 31 23:30:43 2018
@@ -22,11 +22,13 @@
i.scale = 200 # I want to have 200%<br/>
i.name = '/home/subik/test.png'<br/>
i.save()<br/>
+</code>
</p>
<p>Last two lines should be replaced with: <code>i.saveAs('/home/subik/test.png')</code></p>
-<h3>Methods defined here</h3>
+<hr />
+<p>Methods defined here</p>
<dl>
<dt><strong>__init__(...)</strong></strong></dt>
<dd><p>x.__init__(...) initializes x; see x.__class__.__doc__ for signature</p></dd>
@@ -40,29 +42,34 @@
<p>Saves image as 'filename'.</p></dd>
</dl>
-<h3>Data and other attributes defined here</h3>
+<hr />
+<p>Data and other attributes defined here</p>
<dl>
- <dt><strong>__new__ = <built-in method __new__ of type object></strong></dt>
+ <dt><strong>__new__</strong> = <built-in method __new__ of type object></dt>
<dd><p>T.__new__(S, ...) -> a new object with type S, a subtype of T</p></dd>
- <dt><strong>allTypes = <attribute 'allTypes' of 'ImageExport' objects></strong></dt>
+ <dt><strong>allTypes</strong> = <attribute 'allTypes' of 'ImageExport' objects></dt>
<dd><p>Available types. Read only list of strings.</p></dd>
- <dt><strong>dpi = <member 'dpi' of 'ImageExport' objects></strong></dt>
+ <dt><strong>dpi</strong> = <member 'dpi' of 'ImageExport' objects></dt>
<dd><p>This value will be used for export as DPI. Read/write integer.</p></dd>
- <dt><strong>name = <attribute 'name' of 'ImageExport' objects></strong></dt>
+ <dt><strong>name</strong> = <attribute 'name' of 'ImageExport' objects></dt>
<dd><p>Filename of the image. With or without path. Read/write string.</p></dd>
- <dt><strong>quality = <member 'quality' of 'ImageExport' objects></strong></dt>
+ <dt><strong>quality</strong> = <member 'quality' of 'ImageExport' objects></dt>
<dd><p>Quality/compression: minimum 1 (poor), maximum 100 (qaulity). Read/write integer.</p></dd>
- <dt><strong>scale = <member 'scale' of 'ImageExport' objects></strong></dt>
- <dd><p>This is the scaling of the image. 100 = 100% etc. Read/write iteger.</p></dd>
+ <dt><strong>scale</strong> = <member 'scale' of 'ImageExport' objects></dt>
+ <dd><p>This is the scaling of the image. 100 = 100% etc. Read/write integer.</p></dd>
+
+ <dt><strong>transparentBkgnd</strong> = <member 'transparentBkgnd' of 'ImageExport' objects></dt>
+ <dd><p>This value determines if background is drawn as transparent or not. Read/write integer.</p></dd>
- <dt><strong>type = <attribute 'type' of 'ImageExport' objects></strong></dt>
+ <dt><strong>type</strong> = <attribute 'type' of 'ImageExport' objects></dt>
<dd><p>Bitmap type. See allTypes list for more info. Read/write string.</p></dd>
+</dl>
</body>
</html>
Modified: trunk/Scribus/doc/fr/scripterapi-ImageExport.html
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22742&path=/trunk/Scribus/doc/fr/scripterapi-ImageExport.html
==============================================================================
--- trunk/Scribus/doc/fr/scripterapi-ImageExport.html (original)
+++ trunk/Scribus/doc/fr/scripterapi-ImageExport.html Wed Oct 31 23:30:43 2018
@@ -3,6 +3,11 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Python : classe ImageExport</title>
</head>
+
+<style>
+ at import "manual.css";
+</style>
+
<body>
<h2>Python : classe ImageExport</h2>
<p>
@@ -20,12 +25,14 @@
i.scale = 200 # Je veux obtenir 200%<br/>
i.name = '/home/subik/test.png'<br/>
i.save()<br/>
+</code>
</p>
-<p>Les deux dernières lignes devrait être remplacées par ceci :
+<p>Les deux dernières lignes pourraient être remplacées par ceci :
<code>i.saveAs('/home/subik/test.png')</code></p>
-<h3>Méthodes définies ici</h3>
+<hr />
+<p>Méthodes définies par la classe</p>
<dl>
<dt><strong>__init__(...)</strong></strong></dt>
<dd><p>x.__init__(...) initialise x; voir x.__class__.__doc__ pour la signature</p></dd>
@@ -39,28 +46,32 @@
<p>Enregistre l'image sous le nouveau nom "nomFichier".</p></dd>
</dl>
-<h3>Données et autres attributs définis ici</h3>
+<hr />
+<p>Données et attributs définis par la classe</p>
<dl>
- <dt><strong>__new__ = <méthode intégrée __new__ de type objet></strong></dt>
+ <dt><strong>__new__</strong> = <méthode intégrée __new__ de type objet>/dt>
<dd><p>T.__new__(S, ...) -> un nouvel objet de type S, un sous-type de T</p></dd>
- <dt><strong>allTypes = <attribut 'allTypes' des objets 'ImageExport'></strong></dt>
+ <dt><strong>allTypes</strong> = <attribut 'allTypes' de la classe 'ImageExport'></dt>
<dd><p>Types disponibles. Liste de chaînes en lecture seule.</p></dd>
- <dt><strong>dpi = <membre 'dpi' of 'ImageExport' objects></strong></dt>
- <dd><p>Cette valeur sera utilisée pour exportée en DPI. Nombre entier en lecture/écriture.</p></dd>
+ <dt><strong>dpi</strong> = <membre 'dpi' de la classe 'ImageExport'></dt>
+ <dd><p>Cette valeur sera utilisée en tant que résolution d'export de l'image. Nombre entier en lecture/écriture.</p></dd>
- <dt><strong>name = <attribut 'name' des objets 'ImageExport'></strong></dt>
+ <dt><strong>name</strong> = <attribut 'name' de la classe 'ImageExport'></dt>
<dd><p>Nom du fichier associé à l'image. Avec ou sans chemin. Chaîne en lecture/écriture.</p></dd>
- <dt><strong>quality = <membre 'quality' of 'ImageExport' objects></strong></dt>
+ <dt><strong>quality</strong> = <membre 'quality' de la classe 'ImageExport'></dt>
<dd><p>Qualité/compression: minimum 1 (médiocre), maximum 100 (qualité). Nombre entier en lecture/écriture.</p></dd>
- <dt><strong>scale = <membre 'scale' of 'ImageExport' objects></strong></dt>
+ <dt><strong>scale</strong> = <membre 'scale' de la classe 'ImageExport'></dt>
<dd><p>Redimensionnement de l'image. 100 = 100% etc. Nombre entier en lecture/écriture.</p></dd>
- <dt><strong>type = <attribut 'type' des objets 'ImageExport'></strong></dt>
+ <dt><strong>transparentBkgnd</strong> = <membre 'transparentBkgnd' de la classe 'ImageExport'></dt>
+ <dd><p>Détermine si le fond de l'image est transparent ou non. Nombre entier en lecture/écriture.</p></dd>
+
+ <dt><strong>type</strong> = <attribut 'type' de la classe 'ImageExport'></dt>
<dd><p>Type bitmap. Voir la liste allTypes pour plus d'informations. Chaîne en lecture/écriture.</p></dd>
</body>
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22742&path=/trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.cpp Wed Oct 31 23:30:43 2018
@@ -26,6 +26,7 @@
int dpi; // DPI of the bitmap
int scale; // how is bitmap scaled 100 = 100%
int quality; // quality/compression <1; 100>
+ int transparentBkgnd; // background transparency
} ImageExport;
static void ImageExport_dealloc(ImageExport* self)
@@ -50,6 +51,7 @@
self->dpi = 72;
self->scale = 100;
self->quality = 100;
+ self->transparentBkgnd = 0;
}
return (PyObject *) self;
}
@@ -63,6 +65,7 @@
{const_cast<char*>("dpi"), T_INT, offsetof(ImageExport, dpi), 0, imgexp_dpi__doc__},
{const_cast<char*>("scale"), T_INT, offsetof(ImageExport, scale), 0, imgexp_scale__doc__},
{const_cast<char*>("quality"), T_INT, offsetof(ImageExport, quality), 0, imgexp_quality__doc__},
+ {const_cast<char*>("transparentBkgnd"), T_INT, offsetof(ImageExport, transparentBkgnd), 0, imgexp_transparentBkgnd__doc__},
{nullptr, 0, 0, 0, nullptr} // sentinel
};
@@ -150,7 +153,10 @@
* portrait and user defined sizes.
*/
double pixmapSize = (doc->pageHeight() > doc->pageWidth()) ? doc->pageHeight() : doc->pageWidth();
- QImage im = view->PageToPixmap(doc->currentPage()->pageNr(), qRound(pixmapSize * self->scale * (self->dpi / 72.0) / 100.0), Pixmap_DrawBackground);
+ PageToPixmapFlags flags = Pixmap_DrawBackground;
+ if (self->transparentBkgnd)
+ flags &= ~Pixmap_DrawBackground;
+ QImage im = view->PageToPixmap(doc->currentPage()->pageNr(), qRound(pixmapSize * self->scale * (self->dpi / 72.0) / 100.0), flags);
int dpi = qRound(100.0 / 2.54 * self->dpi);
im.setDotsPerMeterY(dpi);
im.setDotsPerMeterX(dpi);
@@ -181,7 +187,10 @@
* portrait and user defined sizes.
*/
double pixmapSize = (doc->pageHeight() > doc->pageWidth()) ? doc->pageHeight() : doc->pageWidth();
- QImage im = view->PageToPixmap(doc->currentPage()->pageNr(), qRound(pixmapSize * self->scale * (self->dpi / 72.0) / 100.0), Pixmap_DrawBackground);
+ PageToPixmapFlags flags = Pixmap_DrawBackground;
+ if (self->transparentBkgnd)
+ flags &= ~Pixmap_DrawBackground;
+ QImage im = view->PageToPixmap(doc->currentPage()->pageNr(), qRound(pixmapSize * self->scale * (self->dpi / 72.0) / 100.0), flags);
int dpi = qRound(100.0 / 2.54 * self->dpi);
im.setDotsPerMeterY(dpi);
im.setDotsPerMeterX(dpi);
Modified: trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22742&path=/trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/objimageexport.h Wed Oct 31 23:30:43 2018
@@ -28,12 +28,13 @@
two last lines should be replaced with:\n\
i.saveAs('/home/subik/test.png')");
+PyDoc_STRVAR(imgexp_alltypes__doc__, "Available image types. Read only list of strings.");
PyDoc_STRVAR(imgexp_dpi__doc__, "This value will be used for export as DPI. Read/write integer.");
+PyDoc_STRVAR(imgexp_filename__doc__, "Filename of the image. With or without path. Read/write string.");
+PyDoc_STRVAR(imgexp_quality__doc__, "Quality/compression: minimum 1 (poor), maximum 100 (qaulity). Read/write integer.");
PyDoc_STRVAR(imgexp_scale__doc__, "This is the scaling of the image. 100 = 100% etc. Read/write iteger.");
-PyDoc_STRVAR(imgexp_quality__doc__, "Quality/compression: minimum 1 (poor), maximum 100 (qaulity). Read/write integer.");
-PyDoc_STRVAR(imgexp_filename__doc__, "Filename of the image. With or without path. Read/write string.");
+PyDoc_STRVAR(imgexp_transparentBkgnd__doc__, "Enable or disable transparent background.");
PyDoc_STRVAR(imgexp_type__doc__, "Bitmap type. See allTypes list for more info. Read/write string.");
-PyDoc_STRVAR(imgexp_alltypes__doc__, "Available types. Read only list of strings.");
PyDoc_STRVAR(imgexp_save__doc__, "save() -> boolean\n\nSaves image under previously set 'name'.");
PyDoc_STRVAR(imgexp_saveas__doc__, "saveAs('filename') -> boolean\n\nSaves image as 'filename'.");
More information about the scribus-commit
mailing list