Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 1334

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qimagewriter.cpp -->
  <title>QImageWriter Class | Qt GUI 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtgui-index.html">Qt GUI</a></td><td ><a href="qtgui-module.html">C++ Classes</a></td><td >QImageWriter</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<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>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QImageWriter Class</h1>
<!-- $$$QImageWriter-brief -->
<p>The <a href="qimagewriter.html">QImageWriter</a> class provides a format independent interface for writing images to files or other devices. <a href="#details">More...</a></p>
<!-- @@@QImageWriter -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QImageWriter&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += gui</td></tr></table></div><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>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><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></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><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-1">QImageWriter</a></b>(QIODevice *<i>device</i>, const QByteArray &amp;<i>format</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#QImageWriter-2">QImageWriter</a></b>(const QString &amp;<i>fileName</i>, const QByteArray &amp;<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"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#optimizedWrite">optimizedWrite</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#progressiveScanWrite">progressiveScanWrite</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 &amp;<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 &amp;<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#setOptimizedWrite">setOptimizedWrite</a></b>(bool <i>optimize</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setProgressiveScanWrite">setProgressiveScanWrite</a></b>(bool <i>progressive</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#setSubType">setSubType</a></b>(const QByteArray &amp;<i>type</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 &amp;<i>key</i>, const QString &amp;<i>text</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#setTransformation">setTransformation</a></b>(QImageIOHandler::Transformations <i>transform</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#subType">subType</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#supportedSubTypes">supportedSubTypes</a></b>() const</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"> QImageIOHandler::Transformations </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#transformation">transformation</a></b>() 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 &amp;<i>image</i>)</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#supportedImageFormats">supportedImageFormats</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qimagewriter.html#supportedMimeTypes">supportedMimeTypes</a></b>()</td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QImageWriter-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qimagewriter.html">QImageWriter</a> class provides a format independent interface for writing images to files or other devices.</p>
<p><a href="qimagewriter.html">QImageWriter</a> 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 <a href="qimagewriter.html">QImageWriter</a> object. Pass either a file name or a device pointer, and the image format to <a href="qimagewriter.html">QImageWriter</a>'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 <code>true</code> if <a href="qimagewriter.html">QImageWriter</a> can write the image (i.e&#x2e;, 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 <a href="qimagewriter.html">QImageWriter</a> can write. <a href="qimagewriter.html">QImageWriter</a> 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" id="ImageWriterError-enum"><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>
<div class="table"><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"><code>QImageWriter::DeviceError</code></td><td class="topAlign tblval"><code>1</code></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"><code>QImageWriter::UnsupportedFormatError</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">Qt does not support the requested image format.</td></tr>
<tr><td class="topAlign"><code>QImageWriter::UnknownError</code></td><td class="topAlign tblval"><code>0</code></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></div>
<!-- @@@ImageWriterError -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QImageWriter[overload1]$$$QImageWriter -->
<h3 class="fn" id="QImageWriter"><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" id="QImageWriter-1"><a name="QImageWriter-1"></a>QImageWriter::<span class="name">QImageWriter</span>(<span class="type"><a href="../qtcore/qiodevice.html">QIODevice</a></span> *<i>device</i>, const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<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" id="QImageWriter-2"><a name="QImageWriter-2"></a>QImageWriter::<span class="name">QImageWriter</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>fileName</i>, const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<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" id="dtor.QImageWriter"><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" id="canWrite"><a name="canWrite"></a><span class="type">bool</span> QImageWriter::<span class="name">canWrite</span>() const</h3>
<p>Returns <code>true</code> if <a href="qimagewriter.html">QImageWriter</a> can write the image; i.e&#x2e;, 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" id="compression"><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" id="device"><a name="device"></a><span class="type"><a href="../qtcore/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" id="error"><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" id="errorString"><a name="errorString"></a><span class="type"><a href="../qtcore/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" id="fileName"><a name="fileName"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QImageWriter::<span class="name">fileName</span>() const</h3>
<p>If the currently assigned device is a <a href="../qtcore/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&#x2e;, if no device has been assigned or the device is not a <a href="../qtcore/qfile.html">QFile</a>), an empty <a href="../qtcore/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" id="format"><a name="format"></a><span class="type"><a href="../qtcore/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" id="gamma"><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 -->
<!-- $$$optimizedWrite[overload1]$$$optimizedWrite -->
<h3 class="fn" id="optimizedWrite"><a name="optimizedWrite"></a><span class="type">bool</span> QImageWriter::<span class="name">optimizedWrite</span>() const</h3>
<p>Returns whether optimization has been turned on for writing the image.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qimagewriter.html#setOptimizedWrite">setOptimizedWrite</a>().</p>
<!-- @@@optimizedWrite -->
<!-- $$$progressiveScanWrite[overload1]$$$progressiveScanWrite -->
<h3 class="fn" id="progressiveScanWrite"><a name="progressiveScanWrite"></a><span class="type">bool</span> QImageWriter::<span class="name">progressiveScanWrite</span>() const</h3>
<p>Returns whether the image should be written as a progressive image.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qimagewriter.html#setProgressiveScanWrite">setProgressiveScanWrite</a>().</p>
<!-- @@@progressiveScanWrite -->
<!-- $$$quality[overload1]$$$quality -->
<h3 class="fn" id="quality"><a name="quality"></a><span class="type">int</span> QImageWriter::<span class="name">quality</span>() const</h3>
<p>Returns the quality setting of the image format.</p>
<p><b>See also </b><a href="qimagewriter.html#setQuality">setQuality</a>().</p>
<!-- @@@quality -->
<!-- $$$setCompression[overload1]$$$setCompressionint -->
<h3 class="fn" id="setCompression"><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 &quot;tiff&quot; 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" id="setDevice"><a name="setDevice"></a><span class="type">void</span> QImageWriter::<span class="name">setDevice</span>(<span class="type"><a href="../qtcore/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="../qtcore/qiodevice.html#OpenModeFlag-enum">QIODevice::WriteOnly</a> mode by calling open(). Note that this does not work for certain devices, such as <a href="../qtcore/qprocess.html">QProcess</a>, <a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a> and <a href="../qtnetwork/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" id="setFileName"><a name="setFileName"></a><span class="type">void</span> QImageWriter::<span class="name">setFileName</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<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="../qtcore/qfile.html">QFile</a> and open it in <a href="../qtcore/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" id="setFormat"><a name="setFormat"></a><span class="type">void</span> QImageWriter::<span class="name">setFormat</span>(const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<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">QImageWriter</a></span> writer;
  writer<span class="operator">.</span>setFormat(<span class="string">&quot;png&quot;</span>); <span class="comment">// same as writer.setFormat(&quot;PNG&quot;);</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" id="setGamma"><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 &quot;png&quot; format supports a gamma range from 0.0 to 1.0&#x2e;</p>
<p><b>See also </b><a href="qimagewriter.html#gamma">gamma</a>() and <a href="qimagewriter.html#quality">quality</a>().</p>
<!-- @@@setGamma -->
<!-- $$$setOptimizedWrite[overload1]$$$setOptimizedWritebool -->
<h3 class="fn" id="setOptimizedWrite"><a name="setOptimizedWrite"></a><span class="type">void</span> QImageWriter::<span class="name">setOptimizedWrite</span>(<span class="type">bool</span> <i>optimize</i>)</h3>
<p>This is an image format-specific function which sets the <i>optimize</i> flags when writing images. For image formats that do not support setting an <i>optimize</i> flag, this value is ignored.</p>
<p>The default is false.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qimagewriter.html#optimizedWrite">optimizedWrite</a>().</p>
<!-- @@@setOptimizedWrite -->
<!-- $$$setProgressiveScanWrite[overload1]$$$setProgressiveScanWritebool -->
<h3 class="fn" id="setProgressiveScanWrite"><a name="setProgressiveScanWrite"></a><span class="type">void</span> QImageWriter::<span class="name">setProgressiveScanWrite</span>(<span class="type">bool</span> <i>progressive</i>)</h3>
<p>This is an image format-specific function which turns on <i>progressive</i> scanning when writing images. For image formats that do not support setting a <i>progressive</i> scan flag, this value is ignored.</p>
<p>The default is false.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qimagewriter.html#progressiveScanWrite">progressiveScanWrite</a>().</p>
<!-- @@@setProgressiveScanWrite -->
<!-- $$$setQuality[overload1]$$$setQualityint -->
<h3 class="fn" id="setQuality"><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>Sets the quality setting of the image format to <i>quality</i>.</p>
<p>Some image formats, in particular lossy ones, entail a tradeoff between a) visual quality of the resulting image, and b) encoding execution time and compression level. This function sets the level of that tradeoff for image formats that support it. For other formats, this value is ignored.</p>
<p>The value range of <i>quality</i> depends on the image format. For example, the &quot;jpeg&quot; format supports a quality range from 0 (low visual quality, high compression) to 100 (high visual quality, low compression).</p>
<p><b>See also </b><a href="qimagewriter.html#quality">quality</a>().</p>
<!-- @@@setQuality -->
<!-- $$$setSubType[overload1]$$$setSubTypeconstQByteArray& -->
<h3 class="fn" id="setSubType"><a name="setSubType"></a><span class="type">void</span> QImageWriter::<span class="name">setSubType</span>(const <span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &amp;<i>type</i>)</h3>
<p>This is an image format specific function that sets the subtype of the image to <i>type</i>. Subtype can be used by a handler to determine which format it should use while saving the image.</p>
<p>For example, saving an image in DDS format with A8R8G8R8 subtype:</p>
<pre class="cpp">

  <span class="type"><a href="qimagewriter.html#QImageWriter">QImageWriter</a></span> writer(<span class="string">&quot;some/image.dds&quot;</span>);
  <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>SubType))
      writer<span class="operator">.</span>setSubType(<span class="string">&quot;A8R8G8B8&quot;</span>);
  writer<span class="operator">.</span>write(image);

</pre>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>See also </b><a href="qimagewriter.html#subType">subType</a>().</p>
<!-- @@@setSubType -->
<!-- $$$setText[overload1]$$$setTextconstQString&constQString& -->
<h3 class="fn" id="setText"><a name="setText"></a><span class="type">void</span> QImageWriter::<span class="name">setText</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<i>key</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &amp;<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">&quot;some/image.jpeg&quot;</span>);
  <span class="type"><a href="qimagewriter.html#QImageWriter">QImageWriter</a></span> writer(<span class="string">&quot;images/outimage.png&quot;</span><span class="operator">,</span> <span class="string">&quot;png&quot;</span>);
  writer<span class="operator">.</span>setText(<span class="string">&quot;Author&quot;</span><span class="operator">,</span> <span class="string">&quot;John Smith&quot;</span>);
  writer<span class="operator">.</span>write(image);

</pre>
<p>If you want to store a single block of data (e.g&#x2e;, a comment), you can pass an empty key, or use a generic key like &quot;Description&quot;.</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 -->
<!-- $$$setTransformation[overload1]$$$setTransformationQImageIOHandler::Transformations -->
<h3 class="fn" id="setTransformation"><a name="setTransformation"></a><span class="type">void</span> QImageWriter::<span class="name">setTransformation</span>(<span class="type"><a href="qimageiohandler.html#Transformation-enum">QImageIOHandler::Transformations</a></span> <i>transform</i>)</h3>
<p>Sets the image transformations metadata including orientation to <i>transform</i>.</p>
<p>If transformation metadata is not supported by the image format, the transform is applied before writing.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qimagewriter.html#transformation">transformation</a>() and <a href="qimagewriter.html#write">write</a>().</p>
<!-- @@@setTransformation -->
<!-- $$$subType[overload1]$$$subType -->
<h3 class="fn" id="subType"><a name="subType"></a><span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span> QImageWriter::<span class="name">subType</span>() const</h3>
<p>Returns the subtype of the image.</p>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>See also </b><a href="qimagewriter.html#setSubType">setSubType</a>().</p>
<!-- @@@subType -->
<!-- $$$supportedImageFormats[overload1]$$$supportedImageFormats -->
<h3 class="fn" id="supportedImageFormats"><a name="supportedImageFormats"></a><code>[static] </code><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageWriter::<span class="name">supportedImageFormats</span>()</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>
<div class="table"><table class="generic">
 <thead><tr class="qt-style"><th >Format</th><th >MIME type</th><th >Description</th></tr></thead>
<tr valign="top" class="odd"><td >BMP</td><td >image/bmp</td><td >Windows Bitmap</td></tr>
<tr valign="top" class="even"><td >JPG</td><td >image/jpeg</td><td >Joint Photographic Experts Group</td></tr>
<tr valign="top" class="odd"><td >PNG</td><td >image/png</td><td >Portable Network Graphics</td></tr>
<tr valign="top" class="even"><td >PBM</td><td >image/x-portable-bitmap</td><td >Portable Bitmap</td></tr>
<tr valign="top" class="odd"><td >PGM</td><td >image/x-portable-graymap</td><td >Portable Graymap</td></tr>
<tr valign="top" class="even"><td >PPM</td><td >image/x-portable-pixmap</td><td >Portable Pixmap</td></tr>
<tr valign="top" class="odd"><td >XBM</td><td >image/x-xbitmap</td><td >X11 Bitmap</td></tr>
<tr valign="top" class="even"><td >XPM</td><td >image/x-xpixmap</td><td >X11 Pixmap</td></tr>
</table></div>
<p>Reading and writing SVG files is supported through the Qt SVG module. The Qt Image Formats module provides support for additional image formats.</p>
<p>Note that the <a href="../qtwidgets/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 -->
<!-- $$$supportedMimeTypes[overload1]$$$supportedMimeTypes -->
<h3 class="fn" id="supportedMimeTypes"><a name="supportedMimeTypes"></a><code>[static] </code><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageWriter::<span class="name">supportedMimeTypes</span>()</h3>
<p>Returns the list of MIME types supported by <a href="qimagewriter.html">QImageWriter</a>.</p>
<p>Note that the <a href="../qtwidgets/qapplication.html">QApplication</a> instance must be created before this function is called.</p>
<p><b>See also </b><a href="qimagewriter.html#supportedImageFormats">supportedImageFormats</a>() and <a href="qimagereader.html#supportedMimeTypes">QImageReader::supportedMimeTypes</a>().</p>
<!-- @@@supportedMimeTypes -->
<!-- $$$supportedSubTypes[overload1]$$$supportedSubTypes -->
<h3 class="fn" id="supportedSubTypes"><a name="supportedSubTypes"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="../qtcore/qbytearray.html">QByteArray</a></span>&gt; QImageWriter::<span class="name">supportedSubTypes</span>() const</h3>
<p>Returns the list of subtypes supported by an image.</p>
<p>This function was introduced in  Qt 5.4.</p>
<!-- @@@supportedSubTypes -->
<!-- $$$supportsOption[overload1]$$$supportsOptionQImageIOHandler::ImageOption -->
<h3 class="fn" id="supportsOption"><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 <code>true</code> 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">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>setText(<span class="string">&quot;Author&quot;</span><span class="operator">,</span> <span class="string">&quot;John Smith&quot;</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 -->
<!-- $$$transformation[overload1]$$$transformation -->
<h3 class="fn" id="transformation"><a name="transformation"></a><span class="type"><a href="qimageiohandler.html#Transformation-enum">QImageIOHandler::Transformations</a></span> QImageWriter::<span class="name">transformation</span>() const</h3>
<p>Returns the transformation and orientation the image has been set to written with.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="qimagewriter.html#setTransformation">setTransformation</a>().</p>
<!-- @@@transformation -->
<!-- $$$write[overload1]$$$writeconstQImage& -->
<h3 class="fn" id="write"><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> &amp;<i>image</i>)</h3>
<p>Writes the image <i>image</i> to the assigned device or file name. Returns <code>true</code> on success; otherwise returns <code>false</code>. 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>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    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.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>