<class name="QImageWriter" doc="/** <p>The <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> class provides a format independent interface for writing images to files or other devices.</p> <p><a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></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 QImage::save() or QPixmap::save() instead.</p> <p>To store an image, you start by constructing a <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> object. Pass either a file name or a device pointer, and the image format to <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>'s constructor. You can then set several options, such as the gamma level (by calling <a href="QImageWriter.html#setGamma(float)"><tt>setGamma</tt></a>) and quality (by calling <a href="QImageWriter.html#setQuality(int)"><tt>setQuality</tt></a>). <a href="QImageWriter.html#canWrite()"><tt>canWrite</tt></a> returns true if <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></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(com.trolltech.qt.gui.QImage)"><tt>write</tt></a> to write the image to the device.</p> <p>If any error occurs when writing the image, <a href="QImageWriter.html#write(com.trolltech.qt.gui.QImage)"><tt>write</tt></a> will return false. You can then call <a href="QImageWriter.html#error()"><tt>error</tt></a> to find the type of error that occurred, or <a href="QImageWriter.html#errorString()"><tt>errorString</tt></a> to get a human readable description of what went wrong.</p> <p>Call <a href="QImageWriter.html#supportedImageFormats()"><tt>supportedImageFormats</tt></a> for a list of formats that <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> can write. <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> supports all built-in image formats, in addition to any image format plugins that support writing.</p> @see <a href="QImageReader.html"><tt>QImageReader</tt></a> @see <a href="QImageIOHandler.html"><tt>QImageIOHandler</tt></a> @see <tt>QImageIOPlugin</tt> */"> <method name="public QImageWriter()" doc="/** <p>Constructs an empty <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> object. Before writing, you must call <a href="QImageWriter.html#setFormat(com.trolltech.qt.core.QByteArray)"><tt>setFormat</tt></a> to set an image format, then <a href="QImageWriter.html#setDevice(com.trolltech.qt.core.QIODevice)"><tt>setDevice</tt></a> or <a href="QImageWriter.html#setFileName(java.lang.String)"><tt>setFileName</tt></a>.</p> */"/> <method name="public QImageWriter(com.trolltech.qt.core.QIODevice device, com.trolltech.qt.core.QByteArray format)" doc="/** <p>Constructs a <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> object using the device <tt>device</tt> and image format <tt>format</tt>.</p> */"/> <method name="public QImageWriter(java.lang.String fileName, com.trolltech.qt.core.QByteArray format)" doc="/** <p>Constructs a <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> objects that will write to a file with the name <tt>fileName</tt>, using the image format <tt>format</tt>. If <tt>format</tt> is not provided, <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> will detect the image format by inspecting the extension of <tt>fileName</tt>.</p> */"/> <method name="public QImageWriter(java.lang.String fileName)" doc="/** <p>Equivalent to <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>(<tt>fileName</tt>, QByteArray()). */"/> <method name="public final boolean canWrite()" doc="/** <p>Returns true if <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> can write the image (i.e&#x2e;, the image format is supported and the assigned device is open for reading.</p> @see <a href="QImageWriter.html#write(com.trolltech.qt.gui.QImage)"><tt>write</tt></a> @see <a href="QImageWriter.html#setDevice(com.trolltech.qt.core.QIODevice)"><tt>setDevice</tt></a> @see <a href="QImageWriter.html#setFormat(com.trolltech.qt.core.QByteArray)"><tt>setFormat</tt></a> */"/> <method name="public final int compression()" doc="/** <p>Returns the compression of the image.</p> @see <a href="QImageWriter.html#setCompression(int)"><tt>setCompression</tt></a> */"/> <method name="public final com.trolltech.qt.core.QIODevice device()" doc="/** <p>Returns the device currently assigned to <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>, or 0 if no device has been assigned.</p> @see <a href="QImageWriter.html#setDevice(com.trolltech.qt.core.QIODevice)"><tt>setDevice</tt></a> */"/> <method name="public final com.trolltech.qt.gui.QImageWriter.ImageWriterError error()" doc="/** <p>Returns the type of error that last occurred.</p> @see <a href="QImageWriter.html#ImageWriterError-enum"><tt>ImageWriterError</tt></a> @see <a href="QImageWriter.html#errorString()"><tt>errorString</tt></a> */"/> <method name="public final java.lang.String errorString()" doc="/** <p>Returns a human readable description of the last error that occurred.</p> @see <a href="QImageWriter.html#error()"><tt>error</tt></a> */"/> <method name="public final java.lang.String fileName()" doc="/** <p>If the currently assigned device is a <a href="%2E%2E/core/QFile.html"><tt>QFile</tt></a>, or if <a href="QImageWriter.html#setFileName(java.lang.String)"><tt>setFileName</tt></a> has been called, this function returns the name of the file <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> writes to. Otherwise (i.e&#x2e;, if no device has been assigned or the device is not a <a href="%2E%2E/core/QFile.html"><tt>QFile</tt></a>), an empty <a href="%2E%2E/porting4.html#qstring"><tt>QString</tt></a> is returned.</p> @see <a href="QImageWriter.html#setFileName(java.lang.String)"><tt>setFileName</tt></a> @see <a href="QImageWriter.html#setDevice(com.trolltech.qt.core.QIODevice)"><tt>setDevice</tt></a> */"/> <method name="public final com.trolltech.qt.core.QByteArray format()" doc="/** <p>Returns the format <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> uses for writing images.</p> @see <a href="QImageWriter.html#setFormat(com.trolltech.qt.core.QByteArray)"><tt>setFormat</tt></a> */"/> <method name="public final float gamma()" doc="/** <p>Returns the gamma level of the image.</p> @see <a href="QImageWriter.html#setGamma(float)"><tt>setGamma</tt></a> */"/> <method name="public final int quality()" doc="/** <p>Returns the quality level of the image.</p> @see <a href="QImageWriter.html#setQuality(int)"><tt>setQuality</tt></a> */"/> <method name="public final void setCompression(int compression)" doc="/** <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 <tt>compression</tt> depends on the image format. For example, the &quot;tiff&quot; format supports two values, 0(no compression) and 1(LZW-compression).</p> @see <a href="QImageWriter.html#compression()"><tt>compression</tt></a> */"/> <method name="public final void setDevice(com.trolltech.qt.core.QIODevice device)" doc="/** <p>Sets <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>'s device to <tt>device</tt>. If a device has already been set, the old device is removed from <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> and is otherwise left unchanged.</p> <p>If the device is not already open, <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> will attempt to open the device in <tt>QIODevice::WriteOnly</tt> mode by calling open(). Note that this does not work for certain devices, such as <a href="%2E%2E/core/QProcess.html"><tt>QProcess</tt></a>, <a href="%2E%2E/network/QTcpSocket.html"><tt>QTcpSocket</tt></a> and <a href="%2E%2E/network/QUdpSocket.html"><tt>QUdpSocket</tt></a>, where more logic is required to open the device.</p> @see <a href="QImageWriter.html#device()"><tt>device</tt></a> @see <a href="QImageWriter.html#setFileName(java.lang.String)"><tt>setFileName</tt></a> */"/> <method name="public final void setFileName(java.lang.String fileName)" doc="/** <p>Sets the file name of <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> to <tt>fileName</tt>. Internally, <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> will create a <a href="%2E%2E/core/QFile.html"><tt>QFile</tt></a> and open it in <tt>QIODevice::WriteOnly</tt> mode, and use this file when writing images.</p> @see <a href="QImageWriter.html#fileName()"><tt>fileName</tt></a> @see <a href="QImageWriter.html#setDevice(com.trolltech.qt.core.QIODevice)"><tt>setDevice</tt></a> */"/> <method name="public final void setFormat(com.trolltech.qt.core.QByteArray format)" doc="/** <p>Sets the format <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> will use when writing images, to <tt>format</tt>. <tt>format</tt> is a case insensitive text string. Example:</p> <pre> QImageWriter writer; writer.setFormat(&quot;png&quot;); <span class="comment">// same as writer.setFormat(&quot;PNG&quot;);</span></pre> <p>You can call <a href="QImageWriter.html#supportedImageFormats()"><tt>supportedImageFormats</tt></a> for the full list of formats <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> supports.</p> @see <a href="QImageWriter.html#format()"><tt>format</tt></a> */"/> <method name="public final void setGamma(float gamma)" doc="/** <p>This is an image format specific function that sets the gamma level of the image to <tt>gamma</tt>. For image formats that do not support setting the gamma level, this value is ignored.</p> <p>The value range of <tt>gamma</tt> depends on the image format. For example, the &quot;png&quot; format supports a gamma range from 0.0 to 1.0&#x2e;</p> @see <a href="QImageWriter.html#gamma()"><tt>gamma</tt></a> @see <a href="QImageWriter.html#quality()"><tt>quality</tt></a> */"/> <method name="public final void setQuality(int quality)" doc="/** <p>This is an image format specific function that sets the quality level of the image to <tt>quality</tt>. For image formats that do not support setting the quality, this value is ignored.</p> <p>The value range of <tt>quality</tt> depends on the image format. For example, the &quot;jpeg&quot; format supports a quality range from 0 (low quality, high compression) to 100 (high quality, low compression).</p> @see <a href="QImageWriter.html#quality()"><tt>quality</tt></a> */"/> <method name="public final void setText(java.lang.String key, java.lang.String text)" doc="/** <p>Sets the image text associated with the key <tt>key</tt> to <tt>text</tt>. This is useful for storing copyright information or other information about the image. Example:</p> <pre> QImage image(&quot;some/image.jpeg&quot;); QImageWriter writer(&quot;images/outimage.png&quot;, &quot;png&quot;); writer.setText(&quot;Author&quot;, &quot;John Smith&quot;); writer.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(com.trolltech.qt.gui.QImage)"><tt>write</tt></a>.</p> <p>Support for this option is implemented through QImageIOHandler::Description.</p> @see <tt>QImage::setText</tt> @see <tt>QImageReader::text</tt> */"/> <method name="public final boolean supportsOption(com.trolltech.qt.gui.QImageIOHandler.ImageOption option)" doc="/** <p>Returns true if the writer supports <tt>option</tt>; 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> QImageWriter writer(fileName); if (writer.supportsOption(QImageIOHandler::Description)) writer.setText(&quot;Author&quot;, &quot;John Smith&quot;);</pre> <p>Options can be tested after the writer has been associated with a format.</p> @see <tt>QImageReader::supportsOption</tt> @see <a href="QImageWriter.html#setFormat(com.trolltech.qt.core.QByteArray)"><tt>setFormat</tt></a> */"/> <method name="public final boolean write(com.trolltech.qt.gui.QImage image)" doc="/** <p>Writes the image <tt>image</tt> 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()"><tt>error</tt></a> to find the type of error that occurred, or <a href="QImageWriter.html#errorString()"><tt>errorString</tt></a> to get a human readable description of the error.</p> @see <a href="QImageWriter.html#canWrite()"><tt>canWrite</tt></a> @see <a href="QImageWriter.html#error()"><tt>error</tt></a> @see <a href="QImageWriter.html#errorString()"><tt>errorString</tt></a> */"/> <method name="public native static java.util.List<com.trolltech.qt.core.QByteArray> supportedImageFormats()" doc="/** <p>Returns the list of image formats supported by <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>.</p> <p>By default, Qt can write the following formats:</p> <p><table align="center" cellpadding="2" cellspacing="1" border="0"> <thead><tr valign="top" 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> @see <a href="QImageWriter.html#setFormat(com.trolltech.qt.core.QByteArray)"><tt>setFormat</tt></a> @see <tt>QImageReader::supportedImageFormats</tt> @see <tt>QImageIOPlugin</tt> */"/> <enum name="ImageWriterError" doc="/** <p>This enum describes errors that can occur when writing images with <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>.</p> */"> <enum-value name="UnknownError" doc="/** <p>An unknown error occurred. If you get this value after calling <a href="QImageWriter.html#write(com.trolltech.qt.gui.QImage)"><tt>write</tt></a>, it is most likely caused by a bug in <a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a>.</p> */"/> <enum-value name="DeviceError" doc="/** <p><a href="QImageWriter.html#QImageWriter(java.lang.String, com.trolltech.qt.core.QByteArray)"><tt>QImageWriter</tt></a> encountered a device error when writing the image data. Consult your device for more details on what went wrong.</p> */"/> <enum-value name="UnsupportedFormatError" doc="/** <p>Qt does not support the requested image format.</p> */"/> </enum> </class>