~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qimagewriter.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/image/qimagewriter.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QImageWriter Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QImageWriter Class Reference</h1>
 
21
<p>The QImageWriter class provides a format independent interface for writing images to files or other devices. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QImageWriter&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
24
<ul>
 
25
<li><a href="qimagewriter-members.html">List of all members, including inherited members</a></li>
 
26
</ul>
 
27
<a name="public-types"></a>
 
28
<h3>Public Types</h3>
 
29
<ul>
 
30
<li><div class="fn"/>enum <b><a href="qimagewriter.html#ImageWriterError-enum">ImageWriterError</a></b> { DeviceError, UnsupportedFormatError, UnknownError }</li>
 
31
</ul>
 
32
<a name="public-functions"></a>
 
33
<h3>Public Functions</h3>
 
34
<ul>
 
35
<li><div class="fn"/><b><a href="qimagewriter.html#QImageWriter">QImageWriter</a></b> ()</li>
 
36
<li><div class="fn"/><b><a href="qimagewriter.html#QImageWriter-2">QImageWriter</a></b> ( QIODevice * <i>device</i>, const QByteArray &amp; <i>format</i> )</li>
 
37
<li><div class="fn"/><b><a href="qimagewriter.html#QImageWriter-3">QImageWriter</a></b> ( const QString &amp; <i>fileName</i>, const QByteArray &amp; <i>format</i> = QByteArray() )</li>
 
38
<li><div class="fn"/><b><a href="qimagewriter.html#dtor.QImageWriter">~QImageWriter</a></b> ()</li>
 
39
<li><div class="fn"/>bool <b><a href="qimagewriter.html#canWrite">canWrite</a></b> () const</li>
 
40
<li><div class="fn"/>QString <b><a href="qimagewriter.html#description">description</a></b> () const</li>
 
41
<li><div class="fn"/>QIODevice * <b><a href="qimagewriter.html#device">device</a></b> () const</li>
 
42
<li><div class="fn"/>ImageWriterError <b><a href="qimagewriter.html#error">error</a></b> () const</li>
 
43
<li><div class="fn"/>QString <b><a href="qimagewriter.html#errorString">errorString</a></b> () const</li>
 
44
<li><div class="fn"/>QString <b><a href="qimagewriter.html#fileName">fileName</a></b> () const</li>
 
45
<li><div class="fn"/>QByteArray <b><a href="qimagewriter.html#format">format</a></b> () const</li>
 
46
<li><div class="fn"/>float <b><a href="qimagewriter.html#gamma">gamma</a></b> () const</li>
 
47
<li><div class="fn"/>int <b><a href="qimagewriter.html#quality">quality</a></b> () const</li>
 
48
<li><div class="fn"/>void <b><a href="qimagewriter.html#setDescription">setDescription</a></b> ( const QString &amp; <i>description</i> )</li>
 
49
<li><div class="fn"/>void <b><a href="qimagewriter.html#setDevice">setDevice</a></b> ( QIODevice * <i>device</i> )</li>
 
50
<li><div class="fn"/>void <b><a href="qimagewriter.html#setFileName">setFileName</a></b> ( const QString &amp; <i>fileName</i> )</li>
 
51
<li><div class="fn"/>void <b><a href="qimagewriter.html#setFormat">setFormat</a></b> ( const QByteArray &amp; <i>format</i> )</li>
 
52
<li><div class="fn"/>void <b><a href="qimagewriter.html#setGamma">setGamma</a></b> ( float <i>gamma</i> )</li>
 
53
<li><div class="fn"/>void <b><a href="qimagewriter.html#setQuality">setQuality</a></b> ( int <i>quality</i> )</li>
 
54
<li><div class="fn"/>bool <b><a href="qimagewriter.html#write">write</a></b> ( const QImage &amp; <i>image</i> )</li>
 
55
</ul>
 
56
<a name="static-public-members"></a>
 
57
<h3>Static Public Members</h3>
 
58
<ul>
 
59
<li><div class="fn"/>QList&lt;QByteArray&gt; <b><a href="qimagewriter.html#supportedImageFormats">supportedImageFormats</a></b> ()</li>
 
60
</ul>
 
61
<a name="details"></a>
 
62
<hr />
 
63
<h2>Detailed Description</h2>
 
64
<p>The QImageWriter class provides a format independent interface for writing images to files or other devices.</p>
 
65
<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>
 
66
<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>
 
67
<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>
 
68
<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>
 
69
<p>See also <a href="qimagereader.html">QImageReader</a>, <a href="qimageiohandler.html">QImageIOHandler</a>, and <a href="qimageioplugin.html">QImageIOPlugin</a>.</p>
 
70
<hr />
 
71
<h2>Member Type Documentation</h2>
 
72
<h3 class="fn"><a name="ImageWriterError-enum"></a>enum QImageWriter::ImageWriterError</h3>
 
73
<p>This enum describes errors that can occur when writing images with <a href="qimagewriter.html">QImageWriter</a>.</p>
 
74
<table border="1" cellpadding="2" cellspacing="1" width="100%">
 
75
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
 
76
<tr><td valign="top"><tt>QImageWriter::DeviceError</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top"><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>
 
77
<tr><td valign="top"><tt>QImageWriter::UnsupportedFormatError</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">Qt does not support the requested image format.</td></tr>
 
78
<tr><td valign="top"><tt>QImageWriter::UnknownError</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">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>
 
79
</table>
 
80
<hr />
 
81
<h2>Member Function Documentation</h2>
 
82
<h3 class="fn"><a name="QImageWriter"></a>QImageWriter::QImageWriter ()</h3>
 
83
<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>
 
84
<h3 class="fn"><a name="QImageWriter-2"></a>QImageWriter::QImageWriter ( <a href="qiodevice.html">QIODevice</a> * <i>device</i>, const <a href="qbytearray.html">QByteArray</a> &amp; <i>format</i> )</h3>
 
85
<p>Constructs a <a href="qimagewriter.html">QImageWriter</a> object using the device <i>device</i> and image format <i>format</i>.</p>
 
86
<h3 class="fn"><a name="QImageWriter-3"></a>QImageWriter::QImageWriter ( const <a href="qstring.html">QString</a> &amp; <i>fileName</i>, const <a href="qbytearray.html">QByteArray</a> &amp; <i>format</i> = QByteArray() )</h3>
 
87
<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>
 
88
<h3 class="fn"><a name="dtor.QImageWriter"></a>QImageWriter::~QImageWriter ()</h3>
 
89
<p>Destructs the <a href="qimagewriter.html">QImageWriter</a> object.</p>
 
90
<h3 class="fn"><a name="canWrite"></a>bool QImageWriter::canWrite () const</h3>
 
91
<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>
 
92
<p>See also <a href="qimagewriter.html#write">write</a>(), <a href="qimagewriter.html#setDevice">setDevice</a>(), and <a href="qimagewriter.html#setFormat">setFormat</a>().</p>
 
93
<h3 class="fn"><a name="description"></a><a href="qstring.html">QString</a> QImageWriter::description () const</h3>
 
94
<p>Returns the description of the image.</p>
 
95
<p>See also <a href="qimagewriter.html#setDescription">setDescription</a>().</p>
 
96
<h3 class="fn"><a name="device"></a><a href="qiodevice.html">QIODevice</a> * QImageWriter::device () const</h3>
 
97
<p>Returns the device currently assigned to <a href="qimagewriter.html">QImageWriter</a>, or 0 if no device has been assigned.</p>
 
98
<h3 class="fn"><a name="error"></a><a href="qimagewriter.html#ImageWriterError-enum">ImageWriterError</a> QImageWriter::error () const</h3>
 
99
<p>Returns the type of error that last occurred.</p>
 
100
<p>See also <a href="qimagewriter.html#ImageWriterError-enum">ImageWriterError</a> and <a href="qimagewriter.html#errorString">errorString</a>().</p>
 
101
<h3 class="fn"><a name="errorString"></a><a href="qstring.html">QString</a> QImageWriter::errorString () const</h3>
 
102
<p>Returns a human readable description of the last error that occurred.</p>
 
103
<p>See also <a href="qimagewriter.html#error">error</a>().</p>
 
104
<h3 class="fn"><a name="fileName"></a><a href="qstring.html">QString</a> QImageWriter::fileName () const</h3>
 
105
<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>
 
106
<p>See also <a href="qimagewriter.html#setFileName">setFileName</a>() and <a href="qimagewriter.html#setDevice">setDevice</a>().</p>
 
107
<h3 class="fn"><a name="format"></a><a href="qbytearray.html">QByteArray</a> QImageWriter::format () const</h3>
 
108
<p>Returns the format <a href="qimagewriter.html">QImageWriter</a> uses for writing images.</p>
 
109
<p>See also <a href="qimagewriter.html#setFormat">setFormat</a>().</p>
 
110
<h3 class="fn"><a name="gamma"></a>float QImageWriter::gamma () const</h3>
 
111
<p>Returns the gamma level of the image.</p>
 
112
<p>See also <a href="qimagewriter.html#setGamma">setGamma</a>().</p>
 
113
<h3 class="fn"><a name="quality"></a>int QImageWriter::quality () const</h3>
 
114
<p>Returns the quality level of the image.</p>
 
115
<p>See also <a href="qimagewriter.html#setQuality">setQuality</a>().</p>
 
116
<h3 class="fn"><a name="setDescription"></a>void QImageWriter::setDescription ( const <a href="qstring.html">QString</a> &amp; <i>description</i> )</h3>
 
117
<p>This is an image format specific function that sets the description of the image to <i>description</i>. For image formats that do not support setting the description, this value is ignored.</p>
 
118
<p>The contents of <i>description</i> depends on the image format.</p>
 
119
<p>See also <a href="qimagewriter.html#description">description</a>().</p>
 
120
<h3 class="fn"><a name="setDevice"></a>void QImageWriter::setDevice ( <a href="qiodevice.html">QIODevice</a> * <i>device</i> )</h3>
 
121
<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>
 
122
<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>
 
123
<p>See also <a href="qimagewriter.html#device">device</a>() and <a href="qimagewriter.html#setFileName">setFileName</a>().</p>
 
124
<h3 class="fn"><a name="setFileName"></a>void QImageWriter::setFileName ( const <a href="qstring.html">QString</a> &amp; <i>fileName</i> )</h3>
 
125
<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>
 
126
<p>See also <a href="qimagewriter.html#fileName">fileName</a>() and <a href="qimagewriter.html#setDevice">setDevice</a>().</p>
 
127
<h3 class="fn"><a name="setFormat"></a>void QImageWriter::setFormat ( const <a href="qbytearray.html">QByteArray</a> &amp; <i>format</i> )</h3>
 
128
<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>
 
129
<pre>&nbsp;   QImageWriter writer;
 
130
    writer.setFormat(&quot;png&quot;); // same as writer.setFormat(&quot;PNG&quot;);</pre>
 
131
<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>
 
132
<p>See also <a href="qimagewriter.html#format">format</a>().</p>
 
133
<h3 class="fn"><a name="setGamma"></a>void QImageWriter::setGamma ( float <i>gamma</i> )</h3>
 
134
<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>
 
135
<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.</p>
 
136
<p>See also <a href="qimagewriter.html#quality">quality</a>().</p>
 
137
<h3 class="fn"><a name="setQuality"></a>void QImageWriter::setQuality ( int <i>quality</i> )</h3>
 
138
<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>
 
139
<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 quality, high compression) to 100 (high quality, low compression).</p>
 
140
<p>See also <a href="qimagewriter.html#quality">quality</a>().</p>
 
141
<h3 class="fn"><a name="supportedImageFormats"></a><a href="qlist.html">QList</a>&lt;<a href="qbytearray.html">QByteArray</a>&gt; QImageWriter::supportedImageFormats ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
142
<p>Returns the list of image formats supported by <a href="qimagewriter.html">QImageWriter</a>.</p>
 
143
<p>See also <a href="qimagewriter.html#setFormat">setFormat</a>() and <a href="qimagereader.html#supportedImageFormats">QImageReader::supportedImageFormats</a>().</p>
 
144
<h3 class="fn"><a name="write"></a>bool QImageWriter::write ( const <a href="qimage.html">QImage</a> &amp; <i>image</i> )</h3>
 
145
<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>
 
146
<p>See also <a href="qimagewriter.html#canWrite">canWrite</a>(), <a href="qimagewriter.html#error">error</a>(), and <a href="qimagewriter.html#errorString">errorString</a>().</p>
 
147
<p /><address><hr /><div align="center">
 
148
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
149
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
150
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
151
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
152
</tr></table></div></address></body>
 
153
</html>