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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qimagewriter.cpp -->
<title>Qt 4.8: QImageWriter Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtgui.html">QtGui</a></li>
<li>QImageWriter</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QImageWriter Class Reference</h1>
<!-- $$$QImageWriter-brief -->
<p>The QImageWriter class provides a format independent interface for writing images to files or other devices. <a href="#details">More...</a></p>
<!-- @@@QImageWriter -->
<pre class="cpp"> <span class="preprocessor">#include <QImageWriter></span></pre><p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qimagewriter-members.html">List of all members, including inherited members</a></li>
<li><a href="qimagewriter-obsolete.html">Obsolete members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#ImageWriterError-enum">ImageWriterError</a></b> { DeviceError, UnsupportedFormatError, UnknownError }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#QImageWriter">QImageWriter</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#QImageWriter-2">QImageWriter</a></b> ( QIODevice * <i>device</i>, const QByteArray & <i>format</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#QImageWriter-3">QImageWriter</a></b> ( const QString & <i>fileName</i>, const QByteArray & <i>format</i> = QByteArray() )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#dtor.QImageWriter">~QImageWriter</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#canWrite">canWrite</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#compression">compression</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QIODevice * </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#device">device</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> ImageWriterError </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#error">error</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#errorString">errorString</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#fileName">fileName</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#format">format</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> float </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#gamma">gamma</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#quality">quality</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setCompression">setCompression</a></b> ( int <i>compression</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setDevice">setDevice</a></b> ( QIODevice * <i>device</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setFileName">setFileName</a></b> ( const QString & <i>fileName</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setFormat">setFormat</a></b> ( const QByteArray & <i>format</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setGamma">setGamma</a></b> ( float <i>gamma</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setQuality">setQuality</a></b> ( int <i>quality</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setText">setText</a></b> ( const QString & <i>key</i>, const QString & <i>text</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#supportsOption">supportsOption</a></b> ( QImageIOHandler::ImageOption <i>option</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#write">write</a></b> ( const QImage & <i>image</i> )</td></tr>
</table>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QList<QByteArray> </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#supportedImageFormats">supportedImageFormats</a></b> ()</td></tr>
</table>
<a name="details"></a>
<!-- $$$QImageWriter-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QImageWriter class provides a format independent interface for writing images to files or other devices.</p>
<p>QImageWriter supports setting format specific options, such as the gamma level, compression level and quality, prior to storing the image. If you do not need such options, you can use <a href="qimage.html#save">QImage::save</a>() or <a href="qpixmap.html#save">QPixmap::save</a>() instead.</p>
<p>To store an image, you start by constructing a QImageWriter object. Pass either a file name or a device pointer, and the image format to QImageWriter's constructor. You can then set several options, such as the gamma level (by calling <a href="qimagewriter.html#setGamma">setGamma</a>()) and quality (by calling <a href="qimagewriter.html#setQuality">setQuality</a>()). <a href="qimagewriter.html#canWrite">canWrite</a>() returns true if QImageWriter can write the image (i.e., the image format is supported and the device is open for writing). Call <a href="qimagewriter.html#write">write</a>() to write the image to the device.</p>
<p>If any error occurs when writing the image, <a href="qimagewriter.html#write">write</a>() will return false. You can then call <a href="qimagewriter.html#error">error</a>() to find the type of error that occurred, or <a href="qimagewriter.html#errorString">errorString</a>() to get a human readable description of what went wrong.</p>
<p>Call <a href="qimagewriter.html#supportedImageFormats">supportedImageFormats</a>() for a list of formats that QImageWriter can write. QImageWriter supports all built-in image formats, in addition to any image format plugins that support writing.</p>
</div>
<p><b>See also </b><a href="qimagereader.html">QImageReader</a>, <a href="qimageiohandler.html">QImageIOHandler</a>, and <a href="qimageioplugin.html">QImageIOPlugin</a>.</p>
<!-- @@@QImageWriter -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ImageWriterError$$$UnknownError$$$DeviceError$$$UnsupportedFormatError -->
<h3 class="fn"><a name="ImageWriterError-enum"></a>enum QImageWriter::<span class="name">ImageWriterError</span></h3>
<p>This enum describes errors that can occur when writing images with <a href="qimagewriter.html">QImageWriter</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QImageWriter::DeviceError</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign"><a href="qimagewriter.html">QImageWriter</a> encountered a device error when writing the image data. Consult your device for more details on what went wrong.</td></tr>
<tr><td class="topAlign"><tt>QImageWriter::UnsupportedFormatError</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">Qt does not support the requested image format.</td></tr>
<tr><td class="topAlign"><tt>QImageWriter::UnknownError</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">An unknown error occurred. If you get this value after calling <a href="qimagewriter.html#write">write</a>(), it is most likely caused by a bug in <a href="qimagewriter.html">QImageWriter</a>.</td></tr>
</table>
<!-- @@@ImageWriterError -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QImageWriter[overload1]$$$QImageWriter -->
<h3 class="fn"><a name="QImageWriter"></a>QImageWriter::<span class="name">QImageWriter</span> ()</h3>
<p>Constructs an empty <a href="qimagewriter.html">QImageWriter</a> object. Before writing, you must call <a href="qimagewriter.html#setFormat">setFormat</a>() to set an image format, then <a href="qimagewriter.html#setDevice">setDevice</a>() or <a href="qimagewriter.html#setFileName">setFileName</a>().</p>
<!-- @@@QImageWriter -->
<!-- $$$QImageWriter$$$QImageWriterQIODevice*constQByteArray& -->
<h3 class="fn"><a name="QImageWriter-2"></a>QImageWriter::<span class="name">QImageWriter</span> ( <span class="type"><a href="qiodevice.html">QIODevice</a></span> * <i>device</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> & <i>format</i> )</h3>
<p>Constructs a <a href="qimagewriter.html">QImageWriter</a> object using the device <i>device</i> and image format <i>format</i>.</p>
<!-- @@@QImageWriter -->
<!-- $$$QImageWriter$$$QImageWriterconstQString&constQByteArray& -->
<h3 class="fn"><a name="QImageWriter-3"></a>QImageWriter::<span class="name">QImageWriter</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>fileName</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> & <i>format</i> = QByteArray() )</h3>
<p>Constructs a <a href="qimagewriter.html">QImageWriter</a> objects that will write to a file with the name <i>fileName</i>, using the image format <i>format</i>. If <i>format</i> is not provided, <a href="qimagewriter.html">QImageWriter</a> will detect the image format by inspecting the extension of <i>fileName</i>.</p>
<!-- @@@QImageWriter -->
<!-- $$$~QImageWriter[overload1]$$$~QImageWriter -->
<h3 class="fn"><a name="dtor.QImageWriter"></a>QImageWriter::<span class="name">~QImageWriter</span> ()</h3>
<p>Destructs the <a href="qimagewriter.html">QImageWriter</a> object.</p>
<!-- @@@~QImageWriter -->
<!-- $$$canWrite[overload1]$$$canWrite -->
<h3 class="fn"><a name="canWrite"></a><span class="type">bool</span> QImageWriter::<span class="name">canWrite</span> () const</h3>
<p>Returns true if <a href="qimagewriter.html">QImageWriter</a> can write the image; i.e., the image format is supported and the assigned device is open for reading.</p>
<p><b>See also </b><a href="qimagewriter.html#write">write</a>(), <a href="qimagewriter.html#setDevice">setDevice</a>(), and <a href="qimagewriter.html#setFormat">setFormat</a>().</p>
<!-- @@@canWrite -->
<!-- $$$compression[overload1]$$$compression -->
<h3 class="fn"><a name="compression"></a><span class="type">int</span> QImageWriter::<span class="name">compression</span> () const</h3>
<p>Returns the compression of the image.</p>
<p><b>See also </b><a href="qimagewriter.html#setCompression">setCompression</a>().</p>
<!-- @@@compression -->
<!-- $$$device[overload1]$$$device -->
<h3 class="fn"><a name="device"></a><span class="type"><a href="qiodevice.html">QIODevice</a></span> * QImageWriter::<span class="name">device</span> () const</h3>
<p>Returns the device currently assigned to <a href="qimagewriter.html">QImageWriter</a>, or 0 if no device has been assigned.</p>
<p><b>See also </b><a href="qimagewriter.html#setDevice">setDevice</a>().</p>
<!-- @@@device -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn"><a name="error"></a><span class="type"><a href="qimagewriter.html#ImageWriterError-enum">ImageWriterError</a></span> QImageWriter::<span class="name">error</span> () const</h3>
<p>Returns the type of error that last occurred.</p>
<p><b>See also </b><a href="qimagewriter.html#ImageWriterError-enum">ImageWriterError</a> and <a href="qimagewriter.html#errorString">errorString</a>().</p>
<!-- @@@error -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn"><a name="errorString"></a><span class="type"><a href="qstring.html">QString</a></span> QImageWriter::<span class="name">errorString</span> () const</h3>
<p>Returns a human readable description of the last error that occurred.</p>
<p><b>See also </b><a href="qimagewriter.html#error">error</a>().</p>
<!-- @@@errorString -->
<!-- $$$fileName[overload1]$$$fileName -->
<h3 class="fn"><a name="fileName"></a><span class="type"><a href="qstring.html">QString</a></span> QImageWriter::<span class="name">fileName</span> () const</h3>
<p>If the currently assigned device is a <a href="qfile.html">QFile</a>, or if <a href="qimagewriter.html#setFileName">setFileName</a>() has been called, this function returns the name of the file <a href="qimagewriter.html">QImageWriter</a> writes to. Otherwise (i.e., if no device has been assigned or the device is not a <a href="qfile.html">QFile</a>), an empty <a href="qstring.html">QString</a> is returned.</p>
<p><b>See also </b><a href="qimagewriter.html#setFileName">setFileName</a>() and <a href="qimagewriter.html#setDevice">setDevice</a>().</p>
<!-- @@@fileName -->
<!-- $$$format[overload1]$$$format -->
<h3 class="fn"><a name="format"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QImageWriter::<span class="name">format</span> () const</h3>
<p>Returns the format <a href="qimagewriter.html">QImageWriter</a> uses for writing images.</p>
<p><b>See also </b><a href="qimagewriter.html#setFormat">setFormat</a>().</p>
<!-- @@@format -->
<!-- $$$gamma[overload1]$$$gamma -->
<h3 class="fn"><a name="gamma"></a><span class="type">float</span> QImageWriter::<span class="name">gamma</span> () const</h3>
<p>Returns the gamma level of the image.</p>
<p><b>See also </b><a href="qimagewriter.html#setGamma">setGamma</a>().</p>
<!-- @@@gamma -->
<!-- $$$quality[overload1]$$$quality -->
<h3 class="fn"><a name="quality"></a><span class="type">int</span> QImageWriter::<span class="name">quality</span> () const</h3>
<p>Returns the quality level of the image.</p>
<p><b>See also </b><a href="qimagewriter.html#setQuality">setQuality</a>().</p>
<!-- @@@quality -->
<!-- $$$setCompression[overload1]$$$setCompressionint -->
<h3 class="fn"><a name="setCompression"></a><span class="type">void</span> QImageWriter::<span class="name">setCompression</span> ( <span class="type">int</span> <i>compression</i> )</h3>
<p>This is an image format specific function that set the compression of an image. For image formats that do not support setting the compression, this value is ignored.</p>
<p>The value range of <i>compression</i> depends on the image format. For example, the "tiff" format supports two values, 0(no compression) and 1(LZW-compression).</p>
<p><b>See also </b><a href="qimagewriter.html#compression">compression</a>().</p>
<!-- @@@setCompression -->
<!-- $$$setDevice[overload1]$$$setDeviceQIODevice* -->
<h3 class="fn"><a name="setDevice"></a><span class="type">void</span> QImageWriter::<span class="name">setDevice</span> ( <span class="type"><a href="qiodevice.html">QIODevice</a></span> * <i>device</i> )</h3>
<p>Sets <a href="qimagewriter.html">QImageWriter</a>'s device to <i>device</i>. If a device has already been set, the old device is removed from <a href="qimagewriter.html">QImageWriter</a> and is otherwise left unchanged.</p>
<p>If the device is not already open, <a href="qimagewriter.html">QImageWriter</a> will attempt to open the device in <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::WriteOnly</a> mode by calling open(). Note that this does not work for certain devices, such as <a href="qprocess.html">QProcess</a>, <a href="qtcpsocket.html">QTcpSocket</a> and <a href="qudpsocket.html">QUdpSocket</a>, where more logic is required to open the device.</p>
<p><b>See also </b><a href="qimagewriter.html#device">device</a>() and <a href="qimagewriter.html#setFileName">setFileName</a>().</p>
<!-- @@@setDevice -->
<!-- $$$setFileName[overload1]$$$setFileNameconstQString& -->
<h3 class="fn"><a name="setFileName"></a><span class="type">void</span> QImageWriter::<span class="name">setFileName</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>fileName</i> )</h3>
<p>Sets the file name of <a href="qimagewriter.html">QImageWriter</a> to <i>fileName</i>. Internally, <a href="qimagewriter.html">QImageWriter</a> will create a <a href="qfile.html">QFile</a> and open it in <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::WriteOnly</a> mode, and use this file when writing images.</p>
<p><b>See also </b><a href="qimagewriter.html#fileName">fileName</a>() and <a href="qimagewriter.html#setDevice">setDevice</a>().</p>
<!-- @@@setFileName -->
<!-- $$$setFormat[overload1]$$$setFormatconstQByteArray& -->
<h3 class="fn"><a name="setFormat"></a><span class="type">void</span> QImageWriter::<span class="name">setFormat</span> ( const <span class="type"><a href="qbytearray.html">QByteArray</a></span> & <i>format</i> )</h3>
<p>Sets the format <a href="qimagewriter.html">QImageWriter</a> will use when writing images, to <i>format</i>. <i>format</i> is a case insensitive text string. Example:</p>
<pre class="cpp"> <span class="type"><a href="qimagewriter.html">QImageWriter</a></span> writer;
writer<span class="operator">.</span>setFormat(<span class="string">"png"</span>); <span class="comment">// same as writer.setFormat("PNG");</span></pre>
<p>You can call <a href="qimagewriter.html#supportedImageFormats">supportedImageFormats</a>() for the full list of formats <a href="qimagewriter.html">QImageWriter</a> supports.</p>
<p><b>See also </b><a href="qimagewriter.html#format">format</a>().</p>
<!-- @@@setFormat -->
<!-- $$$setGamma[overload1]$$$setGammafloat -->
<h3 class="fn"><a name="setGamma"></a><span class="type">void</span> QImageWriter::<span class="name">setGamma</span> ( <span class="type">float</span> <i>gamma</i> )</h3>
<p>This is an image format specific function that sets the gamma level of the image to <i>gamma</i>. For image formats that do not support setting the gamma level, this value is ignored.</p>
<p>The value range of <i>gamma</i> depends on the image format. For example, the "png" format supports a gamma range from 0.0 to 1.0.</p>
<p><b>See also </b><a href="qimagewriter.html#gamma">gamma</a>() and <a href="qimagewriter.html#quality">quality</a>().</p>
<!-- @@@setGamma -->
<!-- $$$setQuality[overload1]$$$setQualityint -->
<h3 class="fn"><a name="setQuality"></a><span class="type">void</span> QImageWriter::<span class="name">setQuality</span> ( <span class="type">int</span> <i>quality</i> )</h3>
<p>This is an image format specific function that sets the quality level of the image to <i>quality</i>. For image formats that do not support setting the quality, this value is ignored.</p>
<p>The value range of <i>quality</i> depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low quality, high compression) to 100 (high quality, low compression).</p>
<p><b>See also </b><a href="qimagewriter.html#quality">quality</a>().</p>
<!-- @@@setQuality -->
<!-- $$$setText[overload1]$$$setTextconstQString&constQString& -->
<h3 class="fn"><a name="setText"></a><span class="type">void</span> QImageWriter::<span class="name">setText</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>key</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>text</i> )</h3>
<p>Sets the image text associated with the key <i>key</i> to <i>text</i>. This is useful for storing copyright information or other information about the image. Example:</p>
<pre class="cpp"> <span class="type"><a href="qimage.html">QImage</a></span> image(<span class="string">"some/image.jpeg"</span>);
<span class="type"><a href="qimagewriter.html">QImageWriter</a></span> writer(<span class="string">"images/outimage.png"</span><span class="operator">,</span> <span class="string">"png"</span>);
writer<span class="operator">.</span>setText(<span class="string">"Author"</span><span class="operator">,</span> <span class="string">"John Smith"</span>);
writer<span class="operator">.</span><a href="qimagewriter.html#write">write</a>(image);</pre>
<p>If you want to store a single block of data (e.g., a comment), you can pass an empty key, or use a generic key like "Description".</p>
<p>The key and text will be embedded into the image data after calling <a href="qimagewriter.html#write">write</a>().</p>
<p>Support for this option is implemented through <a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::Description</a>.</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qimage.html#setText">QImage::setText</a>() and <a href="qimagereader.html#text">QImageReader::text</a>().</p>
<!-- @@@setText -->
<!-- $$$supportedImageFormats[overload1]$$$supportedImageFormats -->
<h3 class="fn"><a name="supportedImageFormats"></a><span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qbytearray.html">QByteArray</a></span>> QImageWriter::<span class="name">supportedImageFormats</span> ()<tt> [static]</tt></h3>
<p>Returns the list of image formats supported by <a href="qimagewriter.html">QImageWriter</a>.</p>
<p>By default, Qt can write the following formats:</p>
<table class="generic">
<thead><tr class="qt-style"><th >Format</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td >BMP</td><td >Windows Bitmap</td></tr>
<tr valign="top" class="even"><td >JPG</td><td >Joint Photographic Experts Group</td></tr>
<tr valign="top" class="odd"><td >JPEG</td><td >Joint Photographic Experts Group</td></tr>
<tr valign="top" class="even"><td >PNG</td><td >Portable Network Graphics</td></tr>
<tr valign="top" class="odd"><td >PPM</td><td >Portable Pixmap</td></tr>
<tr valign="top" class="even"><td >TIFF</td><td >Tagged Image File Format</td></tr>
<tr valign="top" class="odd"><td >XBM</td><td >X11 Bitmap</td></tr>
<tr valign="top" class="even"><td >XPM</td><td >X11 Pixmap</td></tr>
</table>
<p>Reading and writing SVG files is supported through Qt's <a href="qtsvg.html">SVG Module</a>.</p>
<p>Note that the <a href="qapplication.html">QApplication</a> instance must be created before this function is called.</p>
<p><b>See also </b><a href="qimagewriter.html#setFormat">setFormat</a>(), <a href="qimagereader.html#supportedImageFormats">QImageReader::supportedImageFormats</a>(), and <a href="qimageioplugin.html">QImageIOPlugin</a>.</p>
<!-- @@@supportedImageFormats -->
<!-- $$$supportsOption[overload1]$$$supportsOptionQImageIOHandler::ImageOption -->
<h3 class="fn"><a name="supportsOption"></a><span class="type">bool</span> QImageWriter::<span class="name">supportsOption</span> ( <span class="type"><a href="qimageiohandler.html#ImageOption-enum">QImageIOHandler::ImageOption</a></span> <i>option</i> ) const</h3>
<p>Returns true if the writer supports <i>option</i>; otherwise returns false.</p>
<p>Different image formats support different options. Call this function to determine whether a certain option is supported by the current format. For example, the PNG format allows you to embed text into the image's metadata (see text()).</p>
<pre class="cpp"> <span class="type"><a href="qimagewriter.html">QImageWriter</a></span> writer(fileName);
<span class="keyword">if</span> (writer<span class="operator">.</span>supportsOption(<span class="type"><a href="qimageiohandler.html">QImageIOHandler</a></span><span class="operator">::</span>Description))
writer<span class="operator">.</span><a href="qimagewriter.html#setText">setText</a>(<span class="string">"Author"</span><span class="operator">,</span> <span class="string">"John Smith"</span>);</pre>
<p>Options can be tested after the writer has been associated with a format.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qimagereader.html#supportsOption">QImageReader::supportsOption</a>() and <a href="qimagewriter.html#setFormat">setFormat</a>().</p>
<!-- @@@supportsOption -->
<!-- $$$write[overload1]$$$writeconstQImage& -->
<h3 class="fn"><a name="write"></a><span class="type">bool</span> QImageWriter::<span class="name">write</span> ( const <span class="type"><a href="qimage.html">QImage</a></span> & <i>image</i> )</h3>
<p>Writes the image <i>image</i> to the assigned device or file name. Returns true on success; otherwise returns false. If the operation fails, you can call <a href="qimagewriter.html#error">error</a>() to find the type of error that occurred, or <a href="qimagewriter.html#errorString">errorString</a>() to get a human readable description of the error.</p>
<p><b>See also </b><a href="qimagewriter.html#canWrite">canWrite</a>(), <a href="qimagewriter.html#error">error</a>(), and <a href="qimagewriter.html#errorString">errorString</a>().</p>
<!-- @@@write -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|