<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QBitmap Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QBitmap Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QBitmap class provides monochrome (1-bit depth) pixmaps. <a href="#details">More...</a></p> <p>Inherits <a href="qpixmap.html">QPixmap</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qbitmap.html#QBitmap">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbitmap.html#QBitmap-2">__init__</a></b> (<i>self</i>, QPixmap)</li><li><div class="fn" /><b><a href="qbitmap.html#QBitmap-3">__init__</a></b> (<i>self</i>, int <i>w</i>, int <i>h</i>)</li><li><div class="fn" /><b><a href="qbitmap.html#QBitmap-4">__init__</a></b> (<i>self</i>, QSize)</li><li><div class="fn" /><b><a href="qbitmap.html#QBitmap-5">__init__</a></b> (<i>self</i>, QString <i>fileName</i>, str <i>format</i> = None)</li><li><div class="fn" /><b><a href="qbitmap.html#QBitmap-6">__init__</a></b> (<i>self</i>, QVariant <i>variant</i>)</li><li><div class="fn" /><b><a href="qbitmap.html#QBitmap-7">__init__</a></b> (<i>self</i>, QBitmap)</li><li><div class="fn" /><b><a href="qbitmap.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qbitmap.html#swap">swap</a></b> (<i>self</i>, QBitmap <i>other</i>)</li><li><div class="fn" />QBitmap <b><a href="qbitmap.html#transformed">transformed</a></b> (<i>self</i>, QMatrix)</li><li><div class="fn" />QBitmap <b><a href="qbitmap.html#transformed-2">transformed</a></b> (<i>self</i>, QTransform <i>matrix</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QBitmap <b><a href="qbitmap.html#fromData">fromData</a></b> (QSize <i>size</i>, str <i>bits</i>, QImage.Format <i>format</i> = QImage.Format_MonoLSB)</li><li><div class="fn" />QBitmap <b><a href="qbitmap.html#fromImage">fromImage</a></b> (QImage <i>image</i>, Qt.ImageConversionFlags <i>flags</i> = Qt.AutoColor)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QBitmap class provides monochrome (1-bit depth) pixmaps.</p> <p>The QBitmap class is a monochrome off-screen paint device used mainly for creating custom <a href="qcursor.html">QCursor</a> and <a href="qbrush.html">QBrush</a> objects, constructing <a href="qregion.html">QRegion</a> objects, and for setting masks for pixmaps and widgets.</p> <p>QBitmap is a <a href="qpixmap.html">QPixmap</a> subclass ensuring a depth of 1, except for null objects which have a depth of 0. If a pixmap with a depth greater than 1 is assigned to a bitmap, the bitmap will be dithered automatically.</p> <p>Use the <a href="qcolor.html">QColor</a> objects <a href="qt.html#GlobalColor-enum">Qt.color0</a> and <a href="qt.html#GlobalColor-enum">Qt.color1</a> when drawing on a QBitmap object (or a <a href="qpixmap.html">QPixmap</a> object with depth 1).</p> <p>Painting with <a href="qt.html#GlobalColor-enum">Qt.color0</a> sets the bitmap bits to 0, and painting with <a href="qt.html#GlobalColor-enum">Qt.color1</a> sets the bits to 1. For a bitmap, 0-bits indicate background (or transparent pixels) and 1-bits indicate foreground (or opaque pixels). Use the <a href="qbitmap.html#clear">clear</a>() function to set all the bits to <a href="qt.html#GlobalColor-enum">Qt.color0</a>. Note that using the <a href="qt.html#GlobalColor-enum">Qt.black</a> and <a href="qt.html#GlobalColor-enum">Qt.white</a> colors make no sense because the <a class="compat" href="qcolor-qt3.html#pixel">QColor.pixel</a>() value is not necessarily 0 for black and 1 for white.</p> <p>The QBitmap class provides the <a href="qbitmap.html#transformed">transformed</a>() function returning a transformed copy of the bitmap; use the <a href="qtransform.html">QTransform</a> argument to translate, scale, shear, and rotate the bitmap. In addition, QBitmap provides the static <a href="qbitmap.html#fromData">fromData</a>() function which returns a bitmap constructed from the given <tt>uchar</tt> data, and the static <a href="qbitmap.html#fromImage">fromImage</a>() function returning a converted copy of a <a href="qimage.html">QImage</a> object.</p> <p>Just like the <a href="qpixmap.html">QPixmap</a> class, QBitmap is optimized by the use of implicit data sharing. For more information, see the <a href="implicit-sharing.html#implicit-data-sharing">Implicit Data Sharing</a> documentation.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QBitmap" />QBitmap.__init__ (<i>self</i>)</h3><p>Constructs a null bitmap.</p> <p><b>See also</b> <a href="qpixmap.html#isNull">QPixmap.isNull</a>().</p> <h3 class="fn"><a name="QBitmap-2" />QBitmap.__init__ (<i>self</i>, <a href="qpixmap.html">QPixmap</a>)</h3><p>Constructs a bitmap that is a copy of the given <i>pixmap</i>.</p> <p>If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically.</p> <p><b>See also</b> <a href="qpixmap.html#depth">QPixmap.depth</a>(), <a href="qbitmap.html#fromImage">fromImage</a>(), and <a href="qbitmap.html#fromData">fromData</a>().</p> <h3 class="fn"><a name="QBitmap-3" />QBitmap.__init__ (<i>self</i>, int <i>w</i>, int <i>h</i>)</h3><p>Constructs a bitmap with the given <i>width</i> and <i>height</i>. The pixels inside are uninitialized.</p> <p><b>See also</b> <a href="qbitmap.html#clear">clear</a>().</p> <h3 class="fn"><a name="QBitmap-4" />QBitmap.__init__ (<i>self</i>, <a href="qsize.html">QSize</a>)</h3><p>Constructs a bitmap with the given <i>size</i>. The pixels in the bitmap are uninitialized.</p> <p><b>See also</b> <a href="qbitmap.html#clear">clear</a>().</p> <h3 class="fn"><a name="QBitmap-5" />QBitmap.__init__ (<i>self</i>, QString <i>fileName</i>, str <i>format</i> = None)</h3><p>Constructs a bitmap from the file specified by the given <i>fileName</i>. If the file does not exist, or has an unknown format, the bitmap becomes a null bitmap.</p> <p>The <i>fileName</i> and <i>format</i> parameters are passed on to the <a href="qpixmap.html#load">QPixmap.load</a>() function. If the file format uses more than 1 bit per pixel, the resulting bitmap will be dithered automatically.</p> <p><b>See also</b> <a href="qpixmap.html#isNull">QPixmap.isNull</a>() and <a href="qimagereader.html#imageFormat">QImageReader.imageFormat</a>().</p> <h3 class="fn"><a name="QBitmap-6" />QBitmap.__init__ (<i>self</i>, QVariant <i>variant</i>)</h3><h3 class="fn"><a name="QBitmap-7" />QBitmap.__init__ (<i>self</i>, <a href="qbitmap.html">QBitmap</a>)</h3><h3 class="fn"><a name="clear" />QBitmap.clear (<i>self</i>)</h3><p>Clears the bitmap, setting all its bits to <a href="qt.html#GlobalColor-enum">Qt.color0</a>.</p> <h3 class="fn"><a name="fromData" /><a href="qbitmap.html">QBitmap</a> QBitmap.fromData (<a href="qsize.html">QSize</a> <i>size</i>, str <i>bits</i>, <a href="qimage.html#Format-enum">QImage.Format</a> <i>format</i> = QImage.Format_MonoLSB)</h3><p>Constructs a bitmap with the given <i>size</i>, and sets the contents to the <i>bits</i> supplied.</p> <p>The bitmap data has to be byte aligned and provided in in the bit order specified by <i>monoFormat</i>. The mono format must be either <a href="qimage.html#Format-enum">QImage.Format_Mono</a> or <a href="qimage.html#Format-enum">QImage.Format_MonoLSB</a>. Use <a href="qimage.html#Format-enum">QImage.Format_Mono</a> to specify data on the XBM format.</p> <p><b>See also</b> <a href="qbitmap.html#fromImage">fromImage</a>().</p> <h3 class="fn"><a name="fromImage" /><a href="qbitmap.html">QBitmap</a> QBitmap.fromImage (<a href="qimage.html">QImage</a> <i>image</i>, <a href="qt-imageconversionflags.html">Qt.ImageConversionFlags</a> <i>flags</i> = Qt.AutoColor)</h3><p>Returns a copy of the given <i>image</i> converted to a bitmap using the specified image conversion <i>flags</i>.</p> <p><b>See also</b> <a href="qbitmap.html#fromData">fromData</a>().</p> <h3 class="fn"><a name="swap" />QBitmap.swap (<i>self</i>, <a href="qbitmap.html">QBitmap</a> <i>other</i>)</h3><p>Swaps bitmap <i>other</i> with this bitmap. This operation is very fast and never fails.</p> <p>This function was introduced in Qt 4.8.</p> <h3 class="fn"><a name="transformed" /><a href="qbitmap.html">QBitmap</a> QBitmap.transformed (<i>self</i>, <a href="qmatrix.html">QMatrix</a>)</h3><p>Returns a copy of this bitmap, transformed according to the given <i>matrix</i>.</p> <p><b>See also</b> <a href="qpixmap.html#transformed">QPixmap.transformed</a>().</p> <h3 class="fn"><a name="transformed-2" /><a href="qbitmap.html">QBitmap</a> QBitmap.transformed (<i>self</i>, <a href="qtransform.html">QTransform</a> <i>matrix</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>