MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Qt 3 Support Members for QImage

The following class members are part of the Qt 3 support layer. They are provided to help you port old code to Qt 4. We advise against using them in new code.

Public Types

enum Endian { IgnoreEndian, BigEndian, LittleEndian }

Public Functions

QImage ( int width, int height, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
QImage ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
QImage ( uchar * data, int width, int height, int depth, const QRgb * colortable, int numColors, Endian bitOrder )
QImage ( uchar * data, int width, int height, int depth, int bytesPerLine, const QRgb * colortable, int numColors, Endian bitOrder )
QImage ( const QByteArray & data )
Endian bitOrder () const
QImage convertBitOrder ( Endian bitOrder ) const
QImage convertDepth ( int depth, Qt::ImageConversionFlags flags = Qt::AutoColor ) const
QImage convertDepthWithPalette ( int depth, QRgb * palette, int palette_count, Qt::ImageConversionFlags flags = Qt::AutoColor ) const
QImage copy ( int x, int y, int w, int h, Qt::ImageConversionFlags flags ) const
QImage copy ( const QRect & rect, Qt::ImageConversionFlags flags ) const
bool create ( int width, int height, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
bool create ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
bool hasAlphaBuffer () const
void invertPixels ( bool invertAlpha )
uchar ** jumpTable ()
const uchar * const * jumpTable () const
QImage mirror ( bool horizontal = false, bool vertical = true ) const
int numBytes () const
int numColors () const
void reset ()
QImage scaleHeight ( int h ) const
QImage scaleWidth ( int w ) const
void setAlphaBuffer ( bool enable )
void setNumColors ( int numColors )
QImage smoothScale ( int width, int height, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio ) const
QImage smoothScale ( const QSize & size, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio ) const
QImage swapRGB () const
QImage xForm ( const QMatrix & matrix ) const

Static Public Members

Endian systemBitOrder ()
Endian systemByteOrder ()

Related Non-Members

void bitBlt ( QImage * dst, int dx, int dy, const QImage * src, int sx = 0, int sy = 0, int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor )

Member Type Documentation

enum QImage::Endian

This enum type is used to describe the endianness of the CPU and graphics hardware. It is provided here for compatibility with earlier versions of Qt.

Use the Format enum instead. The Format enum specify the endianess for monchrome formats, but for other formats the endianess is not relevant.

Constant Value Description
QImage::IgnoreEndian 2 Endianness does not matter. Useful for some operations that are independent of endianness.
QImage::BigEndian 0 Most significant bit first or network byte order, as on SPARC, PowerPC, and Motorola CPUs.
QImage::LittleEndian 1 Least significant bit first or little endian byte order, as on Intel x86.

Member Function Documentation

QImage::QImage ( int width, int height, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )

Constructs an image with the given width, height, depth, numColors colors and bitOrder.

Use the constructor that accepts a width, a height and a format (i.e. specifying the depth and bit order), in combination with the setColorCount() function, instead.

For example, if you have code like

 QImage image(width, height, depth, numColors);

you can rewrite it as

 QImage image(width, height, format);

 // For 8 bit images the default number of colors is 256. If
 // another number of colors is required it can be specified
 // using the setColorCount() function.
 image.setColorCount(numColors);

QImage::QImage ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )

Constructs an image with the given size, depth, numColors and bitOrder.

Use the constructor that accepts a size and a format (i.e. specifying the depth and bit order), in combination with the setColorCount() function, instead.

For example, if you have code like

 QSize mySize(width, height);
 QImage image(mySize, depth, numColors);

you can rewrite it as

 QSize mySize(width, height);
 QImage image(mySize, format);

 // For 8 bit images the default number of colors is 256. If
 // another number of colors is required it can be specified
 // using the setColorCount() function.
 image.setColorCount(numColors);

QImage::QImage ( uchar * data, int width, int height, int depth, const QRgb * colortable, int numColors, Endian bitOrder )

Constructs an image with the given width, height, depth, colortable, numColors and bitOrder, that uses an existing memory buffer, data.

Use the constructor that accepts a uchar pointer, a width, a height and a format (i.e. specifying the depth and bit order), in combination with the setColorTable() function, instead.

For example, if you have code like

 uchar *myData;
 QRgb *myColorTable;

 QImage image(myData, width, height, depth,
                        myColorTable, numColors, IgnoreEndian);

you can rewrite it as

 uchar *myData;
 QVector<QRgb> myColorTable;

 QImage image(myData, width, height, format);
 image.setColorTable(myColorTable);

QImage::QImage ( uchar * data, int width, int height, int depth, int bytesPerLine, const QRgb * colortable, int numColors, Endian bitOrder )

Constructs an image with the given width, height, depth, bytesPerLine, colortable, numColors and bitOrder, that uses an existing memory buffer, data. The image does not delete the buffer at destruction.

Warning: This constructor is only available in Qt for Embedded Linux.

The data has to be 32-bit aligned, and each scanline of data in the image must also be 32-bit aligned, so it's no longer possible to specify a custom bytesPerLine value.

QImage::QImage ( const QByteArray & data )

Use the static fromData() function instead.

For example, if you have code like

 QByteArray data;
 ...
 QImage image(data);

you can rewrite it as

 QByteArray data;
 ...
 QImage image = QImage::fromData(data);

Endian QImage::bitOrder () const

Returns the bit order for the image. If it is a 1-bpp image, this function returns either QImage::BigEndian or QImage::LittleEndian. Otherwise, this function returns QImage::IgnoreEndian.

Use the format() function instead for the monochrome formats. For non-monochrome formats the bit order is irrelevant.

QImage QImage::convertBitOrder ( Endian bitOrder ) const

Converts the bit order of the image to the given bitOrder and returns the converted image. The original image is not changed. Returns this image if the given bitOrder is equal to the image current bit order, or a null image if this image cannot be converted.

Use convertToFormat() instead.

QImage QImage::convertDepth ( int depth, Qt::ImageConversionFlags flags = Qt::AutoColor ) const

Converts the depth (bpp) of the image to the given depth and returns the converted image. The original image is not changed. Returns this image if depth is equal to the image depth, or a null image if this image cannot be converted. The depth argument must be 1, 8 or 32. If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to specify how you'd prefer this to happen.

Use the convertToFormat() function instead.

QImage QImage::convertDepthWithPalette ( int depth, QRgb * palette, int palette_count, Qt::ImageConversionFlags flags = Qt::AutoColor ) const

Returns an image with the given depth, using the palette_count colors pointed to by palette. If depth is 1 or 8, the returned image will have its color table ordered in the same way as palette.

If the image needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to specify how you'd prefer this to happen.

Note: currently no closest-color search is made. If colors are found that are not in the palette, the palette may not be used at all. This result should not be considered valid because it may change in future implementations.

Currently inefficient for non-32-bit images.

Use the convertToFormat() function in combination with the setColorTable() function instead.

QImage QImage::copy ( int x, int y, int w, int h, Qt::ImageConversionFlags flags ) const

Use copy() instead.

QImage QImage::copy ( const QRect & rect, Qt::ImageConversionFlags flags ) const

Use copy() instead.

bool QImage::create ( int width, int height, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )

Sets the image width, height, depth, its number of colors (in numColors), and bit order. Returns true if successful, or false if the parameters are incorrect or if memory cannot be allocated.

The width and height is limited to 32767. depth must be 1, 8, or 32. If depth is 1, bitOrder must be set to either QImage::LittleEndian or QImage::BigEndian. For other depths bitOrder must be QImage::IgnoreEndian.

This function allocates a color table and a buffer for the image data. The image data is not initialized. The image buffer is allocated as a single block that consists of a table of scanLine() pointers (jumpTable()) and the image data (bits()).

Use a QImage constructor instead.

bool QImage::create ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )

This is an overloaded function.

The width and height are specified in the size argument.

Use a QImage constructor instead.

bool QImage::hasAlphaBuffer () const

Returns true if alpha buffer mode is enabled; otherwise returns false.

Use the hasAlphaChannel() function instead.

void QImage::invertPixels ( bool invertAlpha )

Use the invertPixels() function that takes a QImage::InvertMode parameter instead.

uchar ** QImage::jumpTable ()

Returns a pointer to the scanline pointer table. This is the beginning of the data block for the image. Returns 0 in case of an error.

Use the bits() or scanLine() function instead.

const uchar * const * QImage::jumpTable () const

This is an overloaded function.

QImage QImage::mirror ( bool horizontal = false, bool vertical = true ) const

Use mirrored() instead.

int QImage::numBytes () const

Returns the number of bytes occupied by the image data.

See also byteCount().

int QImage::numColors () const

Returns the size of the color table for the image.

See also setNumColors() and setColorCount().

void QImage::reset ()

Resets all image parameters and deallocates the image data.

Assign a null image instead.

For example, if you have code like

 QImage image;
 image.reset();

you can rewrite it as

 QImage image;
 image = QImage();

QImage QImage::scaleHeight ( int h ) const

Use scaledToHeight() instead.

QImage QImage::scaleWidth ( int w ) const

Use scaledToWidth() instead.

void QImage::setAlphaBuffer ( bool enable )

Enables alpha buffer mode if enable is true, otherwise disables it. The alpha buffer is used to set a mask when a QImage is translated to a QPixmap.

If a monochrome or indexed 8-bit image has alpha channels in their color tables they will automatically detect that they have an alpha channel, so this function is not required. To force alpha channels on 32-bit images, use the convertToFormat() function.

See also hasAlphaBuffer().

void QImage::setNumColors ( int numColors )

Resizes the color table to contain numColors entries.

See also numColors() and setColorCount().

QImage QImage::smoothScale ( int width, int height, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio ) const

Use scaled() instead.

For example, if you have code like

 QImage image;
 image.smoothScale(width, height, mode);

you can rewrite it as

 QImage image;
 image.scaled(width, height, mode, Qt::SmoothTransformation);

QImage QImage::smoothScale ( const QSize & size, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio ) const

This is an overloaded function.

Use scaled() instead.

For example, if you have code like

 QImage image;
 image.smoothScale(size, mode);

you can rewrite it as

 QImage image;
 image.scaled(size, mode, Qt::SmoothTransformation);

QImage QImage::swapRGB () const

Use rgbSwapped() instead.

Endian QImage::systemBitOrder () [static]

Determines the bit order of the display hardware. Returns QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first).

This function is no longer relevant for QImage. Use QSysInfo instead.

Endian QImage::systemByteOrder () [static]

Determines the host computer byte order. Returns QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first).

This function is no longer relevant for QImage. Use QSysInfo instead.

QImage QImage::xForm ( const QMatrix & matrix ) const

Use transformed() instead.

For example, if you have code like

 QImage image;
 ...
 image.xForm(matrix);

you can rewrite it as

 QImage image;
 ...
 image.transformed(matrix);

Related Non-Members

void bitBlt ( QImage * dst, int dx, int dy, const QImage * src, int sx = 0, int sy = 0, int sw = -1, int sh = -1, Qt::ImageConversionFlags flags = Qt::AutoColor )

Copies a block of pixels from src to dst. The pixels copied from source (src) are converted according to flags if it is incompatible with the destination (dst).

sx, sy is the top-left pixel in src, dx, dy is the top-left position in dst and sw, sh is the size of the copied block. The copying is clipped if areas outside src or dst are specified. If sw is -1, it is adjusted to src->width(). Similarly, if sh is -1, it is adjusted to src->height().

Currently inefficient for non 32-bit images.

Use copy() or QPainter::drawImage() instead.