Qt Toolkit - QBitmap Class

# QBitmap Class Reference

The QBitmap class provides monochrome (1 bit depth) pixmaps. More...

`#include <qbitmap.h>`

Inherits QPixmap.

List of all member functions.

## Public Members

- QBitmap ()
- QBitmap ( int w, int h, bool clear = FALSE )
- QBitmap ( const QSize &, bool clear = FALSE )
- QBitmap ( int w, int h, const uchar * bits, bool isXbitmap=FALSE )
- QBitmap ( const QSize &, const uchar * bits, bool isXbitmap=FALSE )
- QBitmap ( const QBitmap & )
- QBitmap ( const char * fileName, const char * format=0 )
- QBitmap& operator= ( const QBitmap & )
- QBitmap& operator= ( const QPixmap & )
- QBitmap& operator= ( const QImage & )
- QBitmap xForm ( const QWMatrix & ) const

## Detailed Description

The QBitmap class provides monochrome (1 bit depth) pixmaps.

The QBitmap class is a monochrome off-screen paint device, used mainly for creating custom mouse cursors or brushes.

A QBitmap is a QPixmap with the depth 1. If a pixmap with a depth greater than 1 is assigned to a bitmap, the bitmap will be automatically dithered. A QBitmap is guaranteed to always have the depth 1, unless it is a null bitmap (has depth 0).

When drawing in a QBitmap (or QPixmap with depth 1), we recommend using the global `color0` and `color1` QColor objects. Painting with `color0` sets the bitmap bits to 0, and painting with `color1` sets the bits to 1. For a bitmap, 0-bits indicate background (or white) and 1-bits indicate foreground (or black). Using the `black` and `white` QColor objects make no sense, because the pixel value is not necessarily 0 for black and 1 for white.

Just like the QPixmap class, QBitmap is optimized by the use of implicit sharing, so it is very efficient to pass QBitmap objects as arguments.

See also: QPixmap, QPainter::drawPixmap(), bitBlt() and Shared Classes

Examples: cursor/cursor.cpp

## Member Function Documentation

### QBitmap::QBitmap ()

Constructs a null bitmap.

See also: QPixmap::isNull().

### QBitmap::QBitmap ( const QSize & size, bool clear = FALSE )

Overloaded constructor; takes a QSize parameter instead of (w,h).

### QBitmap::QBitmap ( const QSize & size, const uchar * bits, bool isXbitmap=FALSE )

Overloaded constructor; takes a QSize parameter instead of (w,h).

### QBitmap::QBitmap ( const QBitmap & bitmap )

Constructs a bitmap which is a copy of bitmap.

### QBitmap::QBitmap ( const char * fileName, const char * format=0 )

Constructs a pixmap from the file fileName. If the file does not exist, or is of an unknown format, the pixmap becomes a null pixmap.

The parameters are passed on to QPixmap::load().

See also: QPixmap::isNull(), QPixmap::load(), QPixmap::loadFromData(), QPixmap::save() and QPixmap::imageFormat().

### QBitmap::QBitmap ( int w, int h, bool clear = FALSE )

Constructs a bitmap with w width and h height.

The contents of the bitmap is uninitialized if clear is FALSE, otherwise it is filled with pixel value 0 (the QColor `color0).`

### QBitmap::QBitmap ( int w, int h, const uchar * bits, bool isXbitmap=FALSE )

Constructs a bitmap with w width and h height and sets the contents to bits.

The isXbitmap should be TRUE if bits was generated by the X11 bitmap program. The X bitmap bit order is little endian. The QImage documentation discusses bit order of monochrome images.

Example (creates an arrow bitmap):

        uchar arrow_bits[] = { 0x3f, 0x1f, 0x0f, 0x1f, 0x3b, 0x71, 0xe0, 0xc0 };
        QBitmap bm( 8, 8, arrow_bits, TRUE );

### QBitmap & QBitmap::operator= ( const QImage & image )

Converts the image image to a bitmap that is assigned to this bitmap. Returns a reference to the bitmap.

Dithering will be performed if the image has a depth greater than 1.

### QBitmap & QBitmap::operator= ( const QPixmap & pixmap )

Assigns the pixmap pixmap to this bitmap and returns a reference to this bitmap.

Dithering will be performed if the pixmap has a depth greater than 1.

### QBitmap & QBitmap::operator= ( const QBitmap & bitmap )

Assigns the bitmap bitmap to this bitmap and returns a reference to this bitmap.

### QBitmap QBitmap::xForm ( const QWMatrix & matrix ) const

Returns a copy of the bitmap that is transformed using matrix.

This function does exactly the same as QPixmap::xForm(), except that it returns a QBitmap instead of a QPixmap.

See also: QPixmap::xForm().

Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):

This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.

It was generated from the following files:

- qbitmap.h: 1998/08/25
- qbitmap.cpp: 1998/09/21