Compatibility Members for QImage

以下成员源于类 QImage are part of the Qt compatibility layer. We advise against using them in new code.

公共类型

enum Endian { IgnoreEndian, BigEndian, LittleEndian }

公共函数

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
void reset ()
QImage scaleHeight (int h ) const
QImage scaleWidth (int w ) const
void setAlphaBuffer (bool enable )
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

静态公共成员

Endian systemBitOrder ()
Endian systemByteOrder ()

相关非成员

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)

成员类型文档编制

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.

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

常量 描述
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.

成员函数文档编制

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

构造图像采用给定 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.

例如,若有代码像

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

可以把它重写成

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)

构造图像采用给定 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.

例如,若有代码像

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

可以把它重写成

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 )

构造图像采用给定 width , height , depth, colortable , numColors and bitOrder ,使用现有内存缓冲 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.

例如,若有代码像

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

可以把它重写成

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 )

构造图像采用给定 width , height , depth , bytesPerLine , colortable , numColors and bitOrder ,使用现有内存缓冲 data . The image does not delete the buffer at destruction.

警告: 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 值。

QImage:: QImage (const QByteArray & data )

Use the static fromData () 函数代替。

例如,若有代码像

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

可以把它重写成

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 .

使用 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.

使用 convertToFormat () 代替。

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.

使用 convertToFormat () 函数代替。

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

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

若需要修改图像以拟合更低分辨率结果 (如:从 32 位转换成 8 位),使用 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.

使用 convertToFormat () function in combination with the setColorTable () 函数代替。

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

使用 copy () 代替。

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

使用 copy () 代替。

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

设置图像 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 必须为 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)

这是重载函数。

The width and height are specified in the size 自变量。

Use a QImage constructor instead.

bool QImage:: hasAlphaBuffer () const

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

使用 hasAlphaChannel () 函数代替。

void QImage:: invertPixels ( bool invertAlpha )

使用 invertPixels () 函数接受 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.

使用 bits () 或 scanLine () 函数代替。

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

这是重载函数。

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

使用 mirrored () 代替。

void QImage:: reset ()

Resets all image parameters and deallocates the image data.

Assign a null image instead.

例如,若有代码像

QImage image;
image.reset();
					

可以把它重写成

QImage image;
image = QImage();
					

QImage QImage:: scaleHeight ( int h ) const

使用 scaledToHeight () 代替。

QImage QImage:: scaleWidth ( int w ) const

使用 scaledToWidth () 代替。

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 () 函数。

另请参阅 hasAlphaBuffer ().

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

使用 scaled () 代替。

例如,若有代码像

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

可以把它重写成

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

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

这是重载函数。

使用 scaled () 代替。

例如,若有代码像

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

可以把它重写成

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

QImage QImage:: swapRGB () const

使用 rgbSwapped () 代替。

[static] Endian QImage:: systemBitOrder ()

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 。使用 QSysInfo 代替。

[static] Endian QImage:: systemByteOrder ()

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

This function is no longer relevant for QImage 。使用 QSysInfo 代替。

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

使用 transformed () 代替。

例如,若有代码像

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

可以把它重写成

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

相关非成员

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 () 代替。