Eneboo - Documentación para desarrolladores
|
The QBitmap class provides monochrome (1-bit depth) pixmaps. Más...
#include <qbitmap.h>
Métodos públicos | |
QBitmap () | |
QBitmap (int w, int h, bool clear=FALSE, QPixmap::Optimization=QPixmap::DefaultOptim) | |
QBitmap (const QSize &, bool clear=FALSE, QPixmap::Optimization=QPixmap::DefaultOptim) | |
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 QString &fileName, const char *format=0) | |
QBitmap & | operator= (const QBitmap &) |
QBitmap & | operator= (const QPixmap &) |
QBitmap & | operator= (const QImage &) |
QBitmap | xForm (const QWMatrix &) const |
QBitmap () | |
QBitmap (int w, int h, bool clear=FALSE, QPixmap::Optimization=QPixmap::DefaultOptim) | |
QBitmap (const QSize &, bool clear=FALSE, QPixmap::Optimization=QPixmap::DefaultOptim) | |
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 QString &fileName, const char *format=0) | |
QBitmap & | operator= (const QBitmap &) |
QBitmap & | operator= (const QPixmap &) |
QBitmap & | operator= (const QImage &) |
QBitmap | xForm (const QWMatrix &) const |
The QBitmap class provides monochrome (1-bit depth) pixmaps.
The QBitmap class is a monochrome off-screen paint device used mainly for creating custom QCursor and QBrush objects, in QPixmap::setMask() and for QRegion.
A QBitmap is a QPixmap with a depth of 1. If a pixmap with a depth greater than 1 is assigned to a bitmap, the bitmap will be dithered automatically. A QBitmap is guaranteed to always have the depth 1, unless it is QPixmap::isNull() which has depth 0.
When drawing in a QBitmap (or QPixmap with depth 1), we recommend using the QColor objects Qt::color0
and Qt::color1
. 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 transparent) and 1-bits indicate foreground (or opaque). Using the black
and white
QColor objects make no sense because the QColor::pixel() value is not necessarily 0 for black and 1 for white.
The QBitmap can be transformed (translated, scaled, sheared or rotated) using xForm().
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.
QBitmap::QBitmap | ( | ) |
Constructs a null bitmap.
QBitmap::QBitmap | ( | int | w, |
int | h, | ||
bool | clear = FALSE , |
||
QPixmap::Optimization | optimization = QPixmap::DefaultOptim |
||
) |
Constructs a bitmap with width w and height h.
The contents of the bitmap is uninitialized if clear is FALSE; otherwise it is filled with pixel value 0 (the QColor Qt::color0
).
The optional optimization argument specifies the optimization setting for the bitmap. The default optimization should be used in most cases. Games and other pixmap-intensive applications may benefit from setting this argument; see {QPixmap::Optimization}.
QBitmap::QBitmap | ( | const QSize & | size, |
bool | clear = FALSE , |
||
QPixmap::Optimization | optimization = QPixmap::DefaultOptim |
||
) |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Constructs a bitmap with the size size.
The contents of the bitmap is uninitialized if clear is FALSE; otherwise it is filled with pixel value 0 (the QColor Qt::color0
).
The optional optimization argument specifies the optimization setting for the bitmap. The default optimization should be used in most cases. Games and other pixmap-intensive applications may benefit from setting this argument; see {QPixmap::Optimization}.
Constructs a bitmap with width w and height h and sets the contents to bits.
The isXbitmap flag 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):
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Constructs a bitmap with the size size and sets the contents to bits.
The isXbitmap flag 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.
QBitmap::QBitmap | ( | const QBitmap & | bitmap | ) |
Constructs a bitmap that is a copy of bitmap.
QBitmap::QBitmap | ( | const QString & | fileName, |
const char * | format = 0 |
||
) |
Constructs a bitmap from the file fileName. If the file does not exist or is of an unknown format, the bitmap becomes a null bitmap.
The parameters fileName and format are passed on to QPixmap::load(). Dithering will be performed if the file format uses more than 1 bit per pixel.
QBitmap::QBitmap | ( | ) |
QBitmap::QBitmap | ( | int | w, |
int | h, | ||
bool | clear = FALSE , |
||
QPixmap::Optimization | = QPixmap::DefaultOptim |
||
) |
QBitmap::QBitmap | ( | const QSize & | , |
bool | clear = FALSE , |
||
QPixmap::Optimization | = QPixmap::DefaultOptim |
||
) |
QBitmap::QBitmap | ( | const QBitmap & | ) |
QBitmap::QBitmap | ( | const QString & | fileName, |
const char * | format = 0 |
||
) |
Assigns the bitmap bitmap to this bitmap and returns a reference to this bitmap.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Assigns the pixmap pixmap to this bitmap and returns a reference to this bitmap.
Dithering will be performed if the pixmap has a QPixmap::depth() greater than 1.
Reimplementado de QPixmap.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Converts the image image to a pixmap that is assigned to this pixmap. Returns a reference to the pixmap.
Reimplementado de QPixmap.
Assigns the pixmap pixmap to this pixmap and returns a reference to this pixmap.
Reimplementado de QPixmap.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Converts the image image to a bitmap and assigns the result to this bitmap. Returns a reference to the bitmap.
Dithering will be performed if the image has a QImage::depth() greater than 1.
Reimplementado de QPixmap.
Returns a transformed copy of this bitmap by using matrix.
This function does exactly the same as QPixmap::xForm(), except that it returns a QBitmap instead of a QPixmap.
Reimplementado de QPixmap.
Returns a copy of the pixmap that is transformed using matrix.
Qt uses this function to implement rotated text on window systems that do not support such complex features.
Example of how to manually draw a rotated text at (100,200) in a widget:
char *str = "Trolls R Qt"; // text to be drawn QFont f( "Charter", 24 ); // use Charter 24pt font QPixmap pm( 8, 8 ); QPainter p; QRect r; // text bounding rectangle QPoint bl; // text baseline position p.begin( &pm ); // first get the bounding p.setFont( f ); // text rectangle r = p.fontMetrics().boundingRect(str); bl = -r.topLeft(); // get baseline position p.end(); pm.resize( r.size() ); // resize to fit the text pm.fill( white ); // fills pm with white p.begin( &pm ); // begin painting pm p.setFont( f ); // set the font p.setPen( blue ); // set blue text color p.drawText( bl, str ); // draw the text p.end(); // painting done QWMatrix m; // transformation matrix m.rotate( -33.4 ); // rotate coordinate system QPixmap rp = pm.xForm( m ); // rp is rotated pixmap QWMatrix t = QPixmap::trueMatrix( m, pm.width(), pm.height() ); int x, y; t.map( bl.x(),bl.y(), &x,&y ); // get pm's baseline pos in rp bitBlt( myWidget, 100-x, 200-y, // blt rp into a widget &rp, 0, 0, -1, -1 );
This example outlines how Qt implements rotated text under X11. The font calculation is the most tedious part. The rotation itself is only 3 lines of code.
If you want to draw rotated text, you do not have to implement all the code above. The code below does exactly the same thing as the example above, except that it uses a QPainter.
char *str = "Trolls R Qt"; // text to be drawn QFont f( "Charter", 24 ); // use Charter 24pt font QPainter p; p.begin( myWidget ); p.translate( 100, 200 ); // translates coord system p.rotate( -33.4 ); // rotates it counterclockwise p.setFont( f ); p.drawText( 0, 0, str ); p.end();
Returns a copy of the pixmap that is transformed using matrix. The original pixmap is not changed.
The transformation matrix is internally adjusted to compensate for unwanted translation, i.e. xForm() returns the smallest image that contains all the transformed points of the original image.
This function is slow because it involves transformation to a QImage, non-trivial computations and a transformation back to a QPixmap.
Reimplementado de QPixmap.