1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QPictureIO Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QPictureIO Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QPictureIO class contains parameters for loading and saving
pictures. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qpictureio.html#QPictureIO">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpictureio.html#QPictureIO-2">__init__</a></b> (<i>self</i>, QIODevice <i>ioDevice</i>, str <i>format</i>)</li><li><div class="fn" /><b><a href="qpictureio.html#QPictureIO-3">__init__</a></b> (<i>self</i>, QString <i>fileName</i>, str <i>format</i>)</li><li><div class="fn" />QString <b><a href="qpictureio.html#description">description</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qpictureio.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qpictureio.html#format">format</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpictureio.html#gamma">gamma</a></b> (<i>self</i>)</li><li><div class="fn" />QIODevice <b><a href="qpictureio.html#ioDevice">ioDevice</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qpictureio.html#parameters">parameters</a></b> (<i>self</i>)</li><li><div class="fn" />QPicture <b><a href="qpictureio.html#picture">picture</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qpictureio.html#quality">quality</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpictureio.html#read">read</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpictureio.html#setDescription">setDescription</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qpictureio.html#setFileName">setFileName</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qpictureio.html#setFormat">setFormat</a></b> (<i>self</i>, str)</li><li><div class="fn" /><b><a href="qpictureio.html#setGamma">setGamma</a></b> (<i>self</i>, float)</li><li><div class="fn" /><b><a href="qpictureio.html#setIODevice">setIODevice</a></b> (<i>self</i>, QIODevice)</li><li><div class="fn" /><b><a href="qpictureio.html#setParameters">setParameters</a></b> (<i>self</i>, str)</li><li><div class="fn" /><b><a href="qpictureio.html#setPicture">setPicture</a></b> (<i>self</i>, QPicture)</li><li><div class="fn" /><b><a href="qpictureio.html#setQuality">setQuality</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qpictureio.html#setStatus">setStatus</a></b> (<i>self</i>, int)</li><li><div class="fn" />int <b><a href="qpictureio.html#status">status</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpictureio.html#write">write</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" /><b><a href="qpictureio.html#defineIOHandler">defineIOHandler</a></b> (str <i>format</i>, str <i>header</i>, str <i>flags</i>, callable <i>read_picture</i>, callable <i>write_picture</i>)</li><li><div class="fn" />list-of-QByteArray <b><a href="qpictureio.html#inputFormats">inputFormats</a></b> ()</li><li><div class="fn" />list-of-QByteArray <b><a href="qpictureio.html#outputFormats">outputFormats</a></b> ()</li><li><div class="fn" />QByteArray <b><a href="qpictureio.html#pictureFormat">pictureFormat</a></b> (QString <i>fileName</i>)</li><li><div class="fn" />QByteArray <b><a href="qpictureio.html#pictureFormat-2">pictureFormat</a></b> (QIODevice)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QPictureIO class contains parameters for loading and saving
pictures.</p>
<p>QPictureIO contains a <a href="qiodevice.html">QIODevice</a>
object that is used for picture data I/O. The programmer can
install new picture file formats in addition to those that Qt
provides.</p>
<p>You don't normally need to use this class; <a href="qpicture.html#load">QPicture.load</a>(), <a href="qpicture.html#save">QPicture.save</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QPictureIO" />QPictureIO.__init__ (<i>self</i>)</h3><p>Constructs a <a class="obsolete" href="qpictureio.html">QPictureIO</a> object with all parameters set to
zero.</p>
<h3 class="fn"><a name="QPictureIO-2" />QPictureIO.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>ioDevice</i>, str <i>format</i>)</h3><p>Constructs a <a class="obsolete" href="qpictureio.html">QPictureIO</a> object with the I/O device
<i>ioDevice</i> and a <i>format</i> tag.</p>
<h3 class="fn"><a name="QPictureIO-3" />QPictureIO.__init__ (<i>self</i>, QString <i>fileName</i>, str <i>format</i>)</h3><p>Constructs a <a class="obsolete" href="qpictureio.html">QPictureIO</a> object with the file name <i>fileName</i>
and a <i>format</i> tag.</p>
<h3 class="fn"><a name="defineIOHandler" />QPictureIO.defineIOHandler (str <i>format</i>, str <i>header</i>, str <i>flags</i>, callable <i>read_picture</i>, callable <i>write_picture</i>)</h3><p>The <i>read_picture</i> argument may also be None.</p><p>The <i>write_picture</i> argument may also be None.</p><p>Defines a picture I/O handler for the picture format called
<i>format</i>, which is recognized using the regular expression
defined in <i>header</i>, read using <i>readPicture</i> and written
using <i>writePicture</i>.</p>
<p><i>flags</i> is a string of single-character flags for this
format. The only flag defined currently is T (upper case), so the
only legal value for <i>flags</i> are "T" and the empty string. The
"T" flag means that the picture file is a text file, and Qt should
treat all newline conventions as equivalent. (XPM files and some
PPM files are text files for example.)</p>
<p><i>format</i> is used to select a handler to write a <a href="qpicture.html">QPicture</a>; <i>header</i> is used to select a
handler to read an picture file.</p>
<p>If <i>readPicture</i> is a null pointer, the <a class="obsolete" href="qpictureio.html">QPictureIO</a> will not be able
to read pictures in <i>format</i>. If <i>writePicture</i> is a null
pointer, the <a class="obsolete" href="qpictureio.html">QPictureIO</a> will not be able to write pictures in
<i>format</i>. If both are null, the <a class="obsolete" href="qpictureio.html">QPictureIO</a> object is valid but useless.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type">void</span> readSVG(<span class="type"><a href="qpictureio.html">QPictureIO</a></span> <span class="operator">*</span>picture)
{
<span class="comment">// read the picture using the picture->ioDevice()</span>
}
<span class="type">void</span> writeSVG(<span class="type"><a href="qpictureio.html">QPictureIO</a></span> <span class="operator">*</span>picture)
{
<span class="comment">// write the picture using the picture->ioDevice()</span>
}
<span class="comment">// add the SVG picture handler</span>
<span class="comment">// ...</span>
</pre>
<p>Before the regular expression test, all the 0 bytes in the file
header are converted to 1 bytes. This is done because when Qt was
ASCII-based, <a href="qregexp.html">QRegExp</a> could not handle 0
bytes in strings.</p>
<p>The regexp is only applied on the first 14 bytes of the
file.</p>
<p>(Note that if one handlerIO supports writing a format and
another supports reading it, Qt supports both reading and writing.
If two handlers support the same operation, Qt chooses one
arbitrarily.)</p>
<h3 class="fn"><a name="description" />QString QPictureIO.description (<i>self</i>)</h3><p>Returns the picture description string.</p>
<p><b>See also</b> <a href="qpictureio.html#setDescription">setDescription</a>().</p>
<h3 class="fn"><a name="fileName" />QString QPictureIO.fileName (<i>self</i>)</h3><p>Returns the file name currently set.</p>
<p><b>See also</b> <a href="qpictureio.html#setFileName">setFileName</a>().</p>
<h3 class="fn"><a name="format" />str QPictureIO.format (<i>self</i>)</h3><p>Returns the picture format string or 0 if no format has been
explicitly set.</p>
<p><b>See also</b> <a href="qpictureio.html#setFormat">setFormat</a>().</p>
<h3 class="fn"><a name="gamma" />float QPictureIO.gamma (<i>self</i>)</h3><p>Returns the gamma value at which the picture will be viewed.</p>
<p><b>See also</b> <a href="qpictureio.html#setGamma">setGamma</a>().</p>
<h3 class="fn"><a name="inputFormats" />list-of-QByteArray QPictureIO.inputFormats ()</h3><p>Returns a sorted list of picture formats that are supported for
picture input.</p>
<h3 class="fn"><a name="ioDevice" /><a href="qiodevice.html">QIODevice</a> QPictureIO.ioDevice (<i>self</i>)</h3><p>Returns the IO device currently set.</p>
<p><b>See also</b> <a href="qpictureio.html#setIODevice">setIODevice</a>().</p>
<h3 class="fn"><a name="outputFormats" />list-of-QByteArray QPictureIO.outputFormats ()</h3><p>Returns a sorted list of picture formats that are supported for
picture output.</p>
<h3 class="fn"><a name="parameters" />str QPictureIO.parameters (<i>self</i>)</h3><p>Returns the picture's parameters string.</p>
<p><b>See also</b> <a href="qpictureio.html#setParameters">setParameters</a>().</p>
<h3 class="fn"><a name="picture" /><a href="qpicture.html">QPicture</a> QPictureIO.picture (<i>self</i>)</h3><p>Returns the picture currently set.</p>
<p><b>See also</b> <a href="qpictureio.html#setPicture">setPicture</a>().</p>
<h3 class="fn"><a name="pictureFormat" /><a href="qbytearray.html">QByteArray</a> QPictureIO.pictureFormat (QString <i>fileName</i>)</h3><p>Returns a string that specifies the picture format of the file
<i>fileName</i>, or null if the file cannot be read or if the
format is not recognized.</p>
<h3 class="fn"><a name="pictureFormat-2" /><a href="qbytearray.html">QByteArray</a> QPictureIO.pictureFormat (<a href="qiodevice.html">QIODevice</a>)</h3><p>This is an overloaded function.</p>
<p>Returns a string that specifies the picture format of the
picture read from IO device <i>d</i>, or 0 if the device cannot be
read or if the format is not recognized.</p>
<p>Make sure that <i>d</i> is at the right position in the device
(for example, at the beginning of the file).</p>
<p><b>See also</b> <a class="compat" href="qiodevice-qt3.html#at">QIODevice.at</a>().</p>
<h3 class="fn"><a name="quality" />int QPictureIO.quality (<i>self</i>)</h3><p>Returns the quality of the written picture, related to the
compression ratio.</p>
<p><b>See also</b> <a href="qpictureio.html#setQuality">setQuality</a>() and <a href="qpicture.html#save">QPicture.save</a>().</p>
<h3 class="fn"><a name="read" />bool QPictureIO.read (<i>self</i>)</h3><p>Reads an picture into memory and returns true if the picture was
successfully read; otherwise returns false.</p>
<p>Before reading an picture you must set an IO device or a file
name. If both an IO device and a file name have been set, the IO
device will be used.</p>
<p>Setting the picture file format string is optional.</p>
<p>Note that this function does <i>not</i> set the <a href="qpictureio.html#format">format</a> used to read the picture. If
you need that information, use the <a href="qpictureio.html#pictureFormat">pictureFormat</a>() static
functions.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type"><a href="qpictureio.html">QPictureIO</a></span> iio;
<span class="type"><a href="qpixmap.html">QPixmap</a></span> pixmap;
iio<span class="operator">.</span>setFileName(<span class="string">"vegeburger.pic"</span>);
<span class="keyword">if</span> (iio<span class="operator">.</span>read()) { <span class="comment">// OK</span>
<span class="type"><a href="qpicture.html">QPicture</a></span> picture <span class="operator">=</span> iio<span class="operator">.</span>picture();
<span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="operator">&</span>pixmap);
painter<span class="operator">.</span>drawPicture(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> picture);
}
</pre>
<p><b>See also</b> <a href="qpictureio.html#setIODevice">setIODevice</a>(), <a href="qpictureio.html#setFileName">setFileName</a>(), <a href="qpictureio.html#setFormat">setFormat</a>(), <a href="qpictureio.html#write">write</a>(), and <a href="qpixmap.html#load">QPixmap.load</a>().</p>
<h3 class="fn"><a name="setDescription" />QPictureIO.setDescription (<i>self</i>, QString)</h3><p>Sets the picture description string for picture handlers that
support picture descriptions to <i>description</i>.</p>
<p>Currently, no picture format supported by Qt uses the
description string.</p>
<p><b>See also</b> <a href="qpictureio.html#description">description</a>().</p>
<h3 class="fn"><a name="setFileName" />QPictureIO.setFileName (<i>self</i>, QString)</h3><p>Sets the name of the file to read or write an picture from to
<i>fileName</i>.</p>
<p><b>See also</b> <a href="qpictureio.html#fileName">fileName</a>() and <a href="qpictureio.html#setIODevice">setIODevice</a>().</p>
<h3 class="fn"><a name="setFormat" />QPictureIO.setFormat (<i>self</i>, str)</h3><p>Sets the picture format to <i>format</i> for the picture to be
read or written.</p>
<p>It is necessary to specify a format before writing an picture,
but it is not necessary to specify a format before reading an
picture.</p>
<p>If no format has been set, Qt guesses the picture format before
reading it. If a format is set the picture will only be read if it
has that format.</p>
<p><b>See also</b> <a href="qpictureio.html#read">read</a>(),
<a href="qpictureio.html#write">write</a>(), and <a href="qpictureio.html#format">format</a>().</p>
<h3 class="fn"><a name="setGamma" />QPictureIO.setGamma (<i>self</i>, float)</h3><p>Sets the gamma value at which the picture will be viewed to
<i>gamma</i>. If the picture format stores a gamma value for which
the picture is intended to be used, then this setting will be used
to modify the picture. Setting to 0.0 will disable gamma correction
(i.e. any specification in the file will be ignored).</p>
<p>The default value is 0.0.</p>
<p><b>See also</b> <a href="qpictureio.html#gamma">gamma</a>().</p>
<h3 class="fn"><a name="setIODevice" />QPictureIO.setIODevice (<i>self</i>, <a href="qiodevice.html">QIODevice</a>)</h3><p>Sets the IO device to be used for reading or writing an
picture.</p>
<p>Setting the IO device allows pictures to be read/written to any
block-oriented <a href="qiodevice.html">QIODevice</a>.</p>
<p>If <i>ioDevice</i> is not null, this IO device will override
file name settings.</p>
<p><b>See also</b> <a href="qpictureio.html#setFileName">setFileName</a>().</p>
<h3 class="fn"><a name="setParameters" />QPictureIO.setParameters (<i>self</i>, str)</h3><p>Sets the picture's parameter string to <i>parameters</i>. This
is for picture handlers that require special parameters.</p>
<p>Although the current picture formats supported by Qt ignore the
parameters string, it may be used in future extensions or by
contributions (for example, JPEG).</p>
<p><b>See also</b> <a href="qpictureio.html#parameters">parameters</a>().</p>
<h3 class="fn"><a name="setPicture" />QPictureIO.setPicture (<i>self</i>, <a href="qpicture.html">QPicture</a>)</h3><p>Sets the picture to <i>picture</i>.</p>
<p><b>See also</b> <a href="qpictureio.html#picture">picture</a>().</p>
<h3 class="fn"><a name="setQuality" />QPictureIO.setQuality (<i>self</i>, int)</h3><p>Sets the quality of the written picture to <i>q</i>, related to
the compression ratio.</p>
<p><i>q</i> must be in the range -1..100. Specify 0 to obtain small
compressed files, 100 for large uncompressed files. (-1 signifies
the default compression.)</p>
<p><b>See also</b> <a href="qpictureio.html#quality">quality</a>()
and <a href="qpicture.html#save">QPicture.save</a>().</p>
<h3 class="fn"><a name="setStatus" />QPictureIO.setStatus (<i>self</i>, int)</h3><p>Sets the picture IO status to <i>status</i>. A non-zero value
indicates an error, whereas 0 means that the IO operation was
successful.</p>
<p><b>See also</b> <a href="qpictureio.html#status">status</a>().</p>
<h3 class="fn"><a name="status" />int QPictureIO.status (<i>self</i>)</h3><p>Returns the picture's IO status. A non-zero value indicates an
error, whereas 0 means that the IO operation was successful.</p>
<p><b>See also</b> <a href="qpictureio.html#setStatus">setStatus</a>().</p>
<h3 class="fn"><a name="write" />bool QPictureIO.write (<i>self</i>)</h3><p>Writes an picture to an IO device and returns true if the
picture was successfully written; otherwise returns false.</p>
<p>Before writing an picture you must set an IO device or a file
name. If both an IO device and a file name have been set, the IO
device will be used.</p>
<p>The picture will be written using the specified picture
format.</p>
<p>Example:</p>
<pre class="cpp">
<span class="type"><a href="qpictureio.html">QPictureIO</a></span> iio;
<span class="type"><a href="qpicture.html">QPicture</a></span> picture;
<span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="operator">&</span>picture);
painter<span class="operator">.</span>drawPixmap(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> pixmap);
iio<span class="operator">.</span>setPicture(picture);
iio<span class="operator">.</span>setFileName(<span class="string">"vegeburger.pic"</span>);
iio<span class="operator">.</span>setFormat(<span class="string">"PIC"</span>);
<span class="keyword">if</span> (iio<span class="operator">.</span>write())
<span class="keyword">return</span> <span class="keyword">true</span>; <span class="comment">// returned true if written successfully</span>
</pre>
<p><b>See also</b> <a href="qpictureio.html#setIODevice">setIODevice</a>(), <a href="qpictureio.html#setFileName">setFileName</a>(), <a href="qpictureio.html#setFormat">setFormat</a>(), <a href="qpictureio.html#read">read</a>(), and <a href="qpixmap.html#save">QPixmap.save</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.11.4 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt 4.8.7</td></tr></table></div></address></body></html>
|