Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QImage Class Reference

Inheritance diagram for QImage:


List of all members.

Detailed Description

The QImage class provides a hardware-independent image representation that allows direct access to the pixel data, and can be used as a paint device.

Qt provides four classes for handling image data: QImage, QPixmap, QBitmap and QPicture. QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen. QBitmap is only a convenience class that inherits QPixmap, ensuring a depth of 1. Finally, the QPicture class is a paint device that records and replays QPainter commands.

Because QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto images. When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread, that is except rendering text (because QFont is GUI dependent). To render text in another thread, the text must first be derived as a QPainterPath in the GUI thread.

The QImage class supports several image formats described by the Format enum. These include monochrome, 8-bit, 32-bit and alpha-blended images which are available in all versions of Qt 4.x. In addition, QImage supports several formats that are specific to {Qtopia Core}.

QImage provides a collection of functions that can be used to obtain a variety of information about the image. There are also several functions that enables transformation of the image.

QImage objects can be passed around by value since the QImage class uses {Implicit Data Sharing}{implicit data sharing}. QImage objects can also be streamed and compared.

Definition at line 82 of file qimage.h.

Public Types

typedef QImageData * DataPtr
enum  Format {
  Format_Invalid, Format_Mono, Format_MonoLSB, Format_Indexed8,
  Format_RGB32, Format_ARGB32, Format_ARGB32_Premultiplied, Format_RGB16,
enum  InvertMode { InvertRgb, InvertRgba }
enum  PaintDeviceMetric {
  PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM,
  PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY,
  PdmPhysicalDpiX, PdmPhysicalDpiY

Public Member Functions

bool allGray () const
QImage alphaChannel () const
const uchar * bits () const
uchar * bits ()
int bytesPerLine () const
qint64 cacheKey () const
QRgb color (int i) const
QVector< QRgb > colorTable () const
QImage convertToFormat (Format f, const QVector< QRgb > &colorTable, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
QImage convertToFormat (Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
QImage copy (int x, int y, int w, int h) const
QImage copy (const QRect &rect=QRect()) const
QImage createAlphaMask (Qt::ImageConversionFlags flags=Qt::AutoColor) const
QImage createHeuristicMask (bool clipTight=true) const
QImage createMaskFromColor (QRgb color, Qt::MaskMode mode=Qt::MaskInColor) const
DataPtrdata_ptr ()
int depth () const
void detach ()
int devType () const
int dotsPerMeterX () const
int dotsPerMeterY () const
void fill (uint pixel)
Format format () const
bool hasAlphaChannel () const
int height () const
int heightMM () const
void invertPixels (InvertMode=InvertRgb)
bool isDetached () const
bool isGrayscale () const
bool isNull () const
bool load (const QString &fileName, const char *format=0)
bool load (QIODevice *device, const char *format)
bool loadFromData (const QByteArray &data, const char *aformat=0)
bool loadFromData (const uchar *buf, int len, const char *format=0)
int logicalDpiX () const
int logicalDpiY () const
QImage mirrored (bool horizontally=false, bool vertically=true) const
int numBytes () const
int numColors () const
QPoint offset () const
 operator QVariant () const
bool operator!= (const QImage &) const
QImageoperator= (const QImage &)
bool operator== (const QImage &) const
QPaintEnginepaintEngine () const
bool paintingActive () const
int physicalDpiX () const
int physicalDpiY () const
QRgb pixel (const QPoint &pt) const
QRgb pixel (int x, int y) const
int pixelIndex (const QPoint &pt) const
int pixelIndex (int x, int y) const
 QImage (const QImage &)
 QImage (const char *fileName, const char *format=0)
 QImage (const QString &fileName, const char *format=0)
 QImage (const char *const xpm[])
 QImage (const uchar *data, int width, int height, int bytesPerLine, Format format)
 QImage (uchar *data, int width, int height, int bytesPerLine, Format format)
 QImage (const uchar *data, int width, int height, Format format)
 QImage (uchar *data, int width, int height, Format format)
 QImage (int width, int height, Format format)
 QImage (const QSize &size, Format format)
 QImage ()
QRect rect () const
QImage rgbSwapped () const
bool save (QIODevice *device, const char *format=0, int quality=-1) const
bool save (const QString &fileName, const char *format=0, int quality=-1) const
QImage scaled (const QSize &s, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
QImage scaled (int w, int h, Qt::AspectRatioMode aspectMode=Qt::IgnoreAspectRatio, Qt::TransformationMode mode=Qt::FastTransformation) const
QImage scaledToHeight (int h, Qt::TransformationMode mode=Qt::FastTransformation) const
QImage scaledToWidth (int w, Qt::TransformationMode mode=Qt::FastTransformation) const
const uchar * scanLine (int) const
uchar * scanLine (int)
int serialNumber () const
void setAlphaChannel (const QImage &alphaChannel)
void setColor (int i, QRgb c)
void setColorTable (const QVector< QRgb > colors)
void setDotsPerMeterX (int)
void setDotsPerMeterY (int)
void setNumColors (int)
void setOffset (const QPoint &)
void setPixel (const QPoint &pt, uint index_or_rgb)
void setPixel (int x, int y, uint index_or_rgb)
void setText (const char *key, const char *lang, const QString &)
void setText (const QString &key, const QString &value)
QSize size () const
QString text (const QImageTextKeyLang &) const
QString text (const char *key, const char *lang=0) const
QString text (const QString &key=QString()) const
QStringList textKeys () const
QStringList textLanguages () const
QList< QImageTextKeyLang > textList () const
QImage transformed (const QTransform &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
QImage transformed (const QMatrix &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
bool valid (const QPoint &pt) const
bool valid (int x, int y) const
int width () const
int widthMM () const
 ~QImage ()

Static Public Member Functions

static QImage fromData (const QByteArray &data, const char *format=0)
static QImage fromData (const uchar *data, int size, const char *format=0)
static QTransform trueMatrix (const QTransform &, int w, int h)
static QMatrix trueMatrix (const QMatrix &, int w, int h)

Protected Member Functions

virtual int metric (PaintDeviceMetric metric) const

Protected Attributes

ushort painters

Private Attributes

QImageData * d


class QDetachedPixmap
class QPixmap
const QVector< QRgb > * qt_image_colortable (const QImage &image)
Q_GUI_EXPORT qint64 qt_image_id (const QImage &image)
class QWSOnScreenSurface

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QImage &image)
QDataStreamoperator>> (QDataStream &stream, QImage &image)
const Q_GUI_EXPORT QX11Infoqt_x11Info (const QPaintDevice *pd)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index