QImage Class Reference
The QImage class provides a hardware-independent pixmap
representation with direct access to the pixel data.
More...
#include <qimage.h>
List of all member functions.
Public Members
enum
Endian { IgnoreEndian, BigEndian, LittleEndian }
QImage ( int w, int h, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
QImage ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
QImage ( const QString & fileName, const char * format = 0 )
QImage ( const QByteArray & array )
QImage ( uchar * yourdata, int w, int h, int depth, QRgb * colortable, int numColors, Endian bitOrder )
QImage ( const QImage & image )
QImage &
operator= ( const QPixmap & pixmap )
QImage
copy ( int x, int y, int w, int h, int conversion_flags = 0 ) const
QImage
copy ( const QRect & r ) const
QRgb
color ( int i ) const
bool
create ( int width, int height, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
bool
create ( const QSize &, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
QImage
convertDepth ( int depth, int conversion_flags ) const
enum
ScaleMode { ScaleFree, ScaleMin, ScaleMax }
QImage
smoothScale ( int w, int h, ScaleMode mode = ScaleFree ) const
QImage
smoothScale ( const QSize & s, ScaleMode mode = ScaleFree ) const
QImage
scale ( int w, int h, ScaleMode mode = ScaleFree ) const
QImage
scale ( const QSize & s, ScaleMode mode = ScaleFree ) const
QImage
xForm ( const QWMatrix & matrix ) const
QImage
mirror ( bool horizontal, bool vertical ) const
bool
load ( const QString & fileName, const char * format = 0 )
bool
loadFromData ( const uchar * buf, uint len, const char * format = 0 )
bool
loadFromData ( QByteArray buf, const char * format = 0 )
bool
save ( const QString & fileName, const char * format, int quality = -1 ) const
bool
valid ( int x, int y ) const
QRgb
pixel ( int x, int y ) const
void
setPixel ( int x, int y, uint index_or_rgb )
QValueList<QImageTextKeyLang>
textList () const
QString
text ( const char * key, const char * lang = 0 ) const
QString
text ( const QImageTextKeyLang & kl ) const
void
setText ( const char * key, const char * lang, const QString & s )
Static Public Members
Related Functions
QDataStream &
operator<< ( QDataStream & s, const QImage & image )
QDataStream &
operator>> ( QDataStream & s, QImage & image )
Detailed Description
The QImage class provides a hardware-independent pixmap
representation with direct access to the pixel data.
It is one of the two classes Qt provides for dealing with images,
the other being QPixmap. QImage is designed and optimized for I/O
and for direct pixel access/manipulation. QPixmap is designed and
optimized for drawing. There are (slow) functions to convert
between QImage and QPixmap: QPixmap::convertToImage() and
QPixmap::convertFromImage().
An image has the parameters width, height and depth (bits per pixel, bpp), a
color table and the actual pixels. QImage supports
1-bpp, 8-bpp and 32-bpp image data. 1-bpp and 8-bpp images use a color
lookup table; the pixel value is a color table index.
32-bpp images encode an RGB value in 24 bits and ignore the color table.
The most significant byte is used for the alpha
buffer.
An entry in the color table is an RGB triplet encoded as uint. Use
the qRed, qGreen and qBlue functions (qcolor.h) to access the
components, and qRgb to make an RGB triplet (see the QColor class
documentation).
1-bpp (monochrome) images have a color table with maximum two colors.
There are two different formats: big endian (MSB first) or little endian
(LSB first) bit order. To access a single bit you will have to do some
bitshifts:
QImage image;
// sets bit at (x,y) to 1
if ( image.bitOrder() == QImage::LittleEndian )
*(image.scanLine(y) + (x >> 3)) |= 1 << (x & 7);
else
*(image.scanLine(y) + (x >> 3)) |= 1 << (7 -(x & 7));
If this looks complicated, it might be a good idea to convert the 1-bpp
image to an 8-bpp image using convertDepth().
8-bpp images are much easier to work with than 1-bpp images because they
have a single byte per pixel:
QImage image;
// set entry 19 in the color table to yellow
image.setColor( 19, qRgb(255,255,0) );
// set 8 bit pixel at (x,y) to value yellow (in color table)
*(image.scanLine(y) + x) = 19;
32-bpp images ignore the color table; instead, each pixel contains the
RGB triplet. 24 bits contain the RGB value; the most significant
byte is reserved for the alpha buffer.
QImage image;
// sets 32 bit pixel at (x,y) to yellow.
uint *p = (uint *)image.scanLine(y) + x;
*p = qRgb(255,255,0);
The scanlines are 32-bit aligned for all depths.
The QImage class uses explicit sharing,
similar to that of QArray.
See also QImageIO, QPixmap and Shared Classes.
Member Type Documentation
QImage::Endian
This enum type is used to describe the endianness of the CPU and
graphics hardware.
The current values are:
- QImage::IgnoreEndian - Does not matter. Useful for some operations
that are independent of endianness.
- QImage::BigEndian - Network byte order, as on SPARC and Motorola CPUs.
- QImage::LittleEndian - PC/Alpha byte order.
QImage::ScaleMode
The functions scale() and smoothScale() use different modes for scaling the
image. The purpose of those modes is to retain the ratio of the image if
wanted.
- QImage::ScaleFree - the image is scaled freely: the resulting image fits exactly
into the specified size.
- QImage::ScaleMin - the ratio of the image is preserved and the resulting image
is guaranteed to fit into the specified size (it is as big as possible
within these constraints) - the image might be smaller than the wished
size.
- QImage::ScaleMax - the ratio of the image is preserved and the resulting image
fills the whole specified rectangle (it is as small as possible within
these constraints) - the image might be biger than the wished size.
Member Function Documentation
QImage::QImage ()
Constructs a null image.
See also isNull().
QImage::QImage ( int w, int h, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
Constructs an image with w width, h height, depth bits per
pixel, numColors colors and bit order bitOrder.
Using this constructor is the same as first constructing a null image and
then calling the create() function.
See also create().
QImage::QImage ( const QSize & size, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
Constructs an image with size size pixels, depth depth
bits, numColors and bitOrder endianness.
QImage::QImage ( const QString & fileName, const char * format = 0 )
Constructs an image from loading fileName and an optional
format.
See also load().
QImage::QImage ( const char * xpm[] )
Constructs an image from xpm, which must be a valid XPM image.
Errors are silently ignored.
Note that it's possible to squeeze the XPM variable a little bit by
using an unusual declaration:
static const char * const start_xpm[]={
"16 15 8 1",
"a c #cec6bd",
....
The extra const makes the entire definition read-only, which is
slightly more efficient (e.g., when the code is in a shared library)
and ROMable when the application is to be stored in ROM.
In order to use that sort of declaration, you must cast the variable
back to const char **
when you create the
QImage.
QImage::QImage ( const QByteArray & array )
Constructs an image from array, which must be in a supported
image format image.
See also loadFromData().
QImage::QImage ( uchar * yourdata, int w, int h, int depth, QRgb * colortable, int numColors, Endian bitOrder )
Constructs an image that uses an existing memory buffer.
The buffer must remain valid throughout the life of the QImage. The image
does not delete the buffer at destruction.
If colortable is 0, a color table sufficient for numColors will be
allocated (and destructed later).
QImage::QImage ( const QImage & image )
Constructs a
shallow copy of image.
QImage::~QImage ()
Destroys the image and cleans up.
bool QImage::allGray () const
Returns TRUE if all the colors in the image are shades of
gray (i.e., their R, G and B components are equal).
This function is slow for large 16-bit and 32-bit images.
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.
If it is not a 1-bpp image, this function returns QImage::IgnoreEndian.
See also depth().
uchar * QImage::bits () const
Returns a pointer to the first pixel data. Equivalent to scanLine(0).
See also scanLine().
Example: opengl/texture/gltexobj.cpp.
int QImage::bytesPerLine () const
Returns the number of bytes per image scanline.
This is equivalent to numBytes()/height().
QRgb QImage::color ( int i ) const
Returns the color in the color table at index i.
A color value is an RGB triplet. Use the qRed(), qGreen() and qBlue()
functions (defined in qcolor.h) to get the color value components.
See also setColor() and QColor.
Example: themes/wood.cpp.
QRgb * QImage::colorTable () const
Returns a pointer to the color table.
QImage QImage::convertBitOrder ( Endian bitOrder ) const
Converts the bit order of the image to bitOrder and returns the converted
image.
Returns *this if the bitOrder is equal to the image bit order, or a
null image if this image cannot be converted.
See also bitOrder() and systemBitOrder().
QImage QImage::convertDepth ( int depth, int conversion_flags ) const
Converts the depth (bpp) of the image to depth and returns the
converted image. The original image is left undisturbed.
The depth argument must be 1, 8, 16 or 32.
See QPixmap::convertFromImage() for a description of the conversion_flags argument.
Returns *this if depth is equal to the image depth, or a null
image if this image cannot be converted.
See also depth() and isNull().
QImage QImage::convertDepth ( int depth ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
QImage QImage::convertDepthWithPalette ( int d, QRgb * palette, int palette_count, int conversion_flags = 0 ) const
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.
QImage QImage::copy () const
Returns a
deep copy of the image.
QImage QImage::copy ( int x, int y, int w, int h, int conversion_flags = 0 ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a
deep copy of a sub-area of the image.
The returned image is always w by h pixels in size.
In areas beyond this image pixels are filled with pixel 0.
See also bitBlt().
QImage QImage::copy ( const QRect & r ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns a
deep copy of a sub-area of the image.
The returned image has always the size of the rectangle r.
In areas beyond this image pixels are filled with pixel 0.
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()).
See also width(), height(), depth(), numColors(), bitOrder(), jumpTable(), scanLine(), bits(), bytesPerLine() and numBytes().
bool QImage::create ( const QSize &, int depth, int numColors = 0, Endian bitOrder = IgnoreEndian )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
QImage QImage::createAlphaMask ( int conversion_flags = 0 ) const
Builds and returns a 1-bpp mask from the alpha buffer in this image.
Returns a null image if alpha buffer mode
is disabled.
See QPixmap::convertFromImage() for a description of the conversion_flags argument.
The returned image has little-endian bit order, which you can
convert to big-endianness using convertBitOrder().
QImage QImage::createHeuristicMask ( bool clipTight = TRUE ) const
Creates and returns a 1-bpp heuristic mask for this image. It works by
selecting a color from one of the corners, then chipping away pixels of
that color starting at all the edges.
The four corners vote which color is to be masked away. In
case of a draw (this generally means that this function is not
applicable to the image), the result is arbitrary.
The returned image has little-endian bit order, which you can
convert to big-endianness using convertBitOrder().
This function disregards the alpha buffer.
int QImage::depth () const
Returns the depth of the image.
The image depth is the number of bits used to encode a single pixel, also
called bits per pixel (bpp) or bit planes of an image.
The supported depths are 1, 8, 16 and 32.
See also convertDepth().
void QImage::detach ()
Detaches from shared image data and makes sure that this image is the
only one referring the data.
If multiple images share common data, this image makes a copy of the
data and detaches itself from the sharing mechanism. Nothing is
done if there is just a single reference.
Example: themes/wood.cpp.
int QImage::dotsPerMeterX () const
Returns the number of pixels that fit horizontally in a physical meter.
This and dotsPerMeterY() define the intended scale and aspect ratio
of the image.
See also setDotsPerMeterX().
int QImage::dotsPerMeterY () const
Returns the number of pixels that fit vertically in a physical meter.
This and dotsPerMeterX() define the intended scale and aspect ratio
of the image.
See also setDotsPerMeterY().
void QImage::fill ( uint pixel )
Fills the entire image with the pixel value pixel.
If the depth of this image is 1, only
the lowest bit is used. If you say fill(0), fill(2), etc., the image
is filled with 0s. If you say fill(1), fill(3), etc., the image
is filled with 1s. If the depth is 8, the lowest 8 bits are used.
If the depth is 32 and the image has no alpha buffer, the pixel
value is written to each pixel in the image. If the image has an
alpha buffer, only the 24 RGB bits are set and the upper 8 bits (alpha
value) are left unchanged.
bool QImage::hasAlphaBuffer () const
Returns TRUE if alpha buffer mode is enabled, otherwise FALSE.
See also setAlphaBuffer().
int QImage::height () const
Returns the height of the image.
See also width(), size() and rect().
Example: opengl/texture/gltexobj.cpp.
const char * QImage::imageFormat ( const QString & fileName ) [static]
Returns a string that specifies the image format of the file fileName,
or null if the file cannot be read or if the format cannot be recognized.
The QImageIO documentation lists the guaranteed supported image
formats, or use the QImage::inputFormats() QImage::outputFormats()
to get lists that include installed formats.
See also load() and save().
QStringList QImage::inputFormatList () [static]
Returns a list of image formats that are supported for image input.
Example: showimg/showimg.cpp.
QStrList QImage::inputFormats () [static]
Returns a list of image formats that are supported for image input.
See also inputFormatList().
void QImage::invertPixels ( bool invertAlpha = TRUE )
Inverts all pixel values in the image.
For 32 bit (24 RGB + alpha buffer) images, set invertAlpha to
FALSE if you want the alpha bits to be unchanged; otherwise they are
inverted, too.
bool QImage::isGrayscale () const
Returns TRUE if the image is allGray(), and if the image is 32-bpp
or a 256-color 8-bpp image for which color(i) is QRgb(i,i,i).
bool QImage::isNull () const
Returns TRUE if it is a null image.
A null image has all parameters set to zero and no allocated data.
Examples: qtimage/qtimage.cpp and showimg/showimg.cpp.
uchar ** QImage::jumpTable () const
Returns a pointer to the scanline pointer table.
This is the beginning of the data block for the image.
bool QImage::load ( const QString & fileName, const char * format = 0 )
Loads an image from the file fileName.
Returns TRUE if successful, or FALSE if the image could not be loaded.
If format is specified, the loader attempts to read the image using the
specified format. If format is not specified (default),
the loader reads a few bytes from the header to guess the file format.
The QImageIO documentation lists the supported image formats and
explains how to add extra formats.
See also loadFromData(), save(), imageFormat(), QPixmap::load() and QImageIO.
bool QImage::loadFromData ( const uchar * buf, uint len, const char * format = 0 )
Loads an image from the binary data in buf (len bytes).
Returns TRUE if successful, or FALSE if the image could not be loaded.
If format is specified, the loader attempts to read the image using the
specified format. If format is not specified (default),
the loader reads a few bytes from the header to guess the file format.
The QImageIO documentation lists the supported image formats and
explains how to add extra formats.
See also load(), save(), imageFormat(), QPixmap::loadFromData() and QImageIO.
bool QImage::loadFromData ( QByteArray buf, const char * format = 0 )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Loads from a QByteArray.
QImage QImage::mirror () const
Returns a QImage which is a vertically mirrored copy of this
image. The original QImage is left unchanged.
QImage QImage::mirror ( bool horizontal, bool vertical ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the image mirrored in horizontal and/or vertical direction
depending on whether horizontal and vertical are set to
TRUE or FALSE.
See also smoothScale().
int QImage::numBytes () const
Returns the number of bytes occupied by the image data.
See also bytesPerLine().
int QImage::numColors () const
Returns the size of the color table for the image.
Notice that numColors() returns 0 for 16-bpp and 32-bpp images
because these images do not use color tables, but instead encode pixel
values as RGB triplets.
Example: themes/wood.cpp.
QPoint QImage::offset () const
Returns the number of pixels by which the image is intended to be
offset by when positioning relative to other images.
bool QImage::operator!= ( const QImage & i ) const
Returns TRUE if this image and i have different contents and
FALSE if they they have the same. This can be slow. Of course,
this function returns quickly if the two images' widths are
different, or there is some other obvious difference.
See also operator=().
QImage & QImage::operator= ( const QImage & image )
Assigns a
shallow copy
of image to this image and returns a reference to this image.
See also copy().
QImage & QImage::operator= ( const QPixmap & pixmap )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Sets the image bits to the pixmap contents and returns a reference to
the image.
If the image shares data with other images, it will first dereference
the shared data.
Makes a call to QPixmap::convertToImage().
bool QImage::operator== ( const QImage & i ) const
Returns TRUE if this image and i have the same contents and
FALSE if they differ. This can be slow. Of course, this function
returns quickly if the two images' widths are different, or there is
some other obvious difference.
See also operator=().
QStringList QImage::outputFormatList () [static]
Returns a list of image formats that are supported for image output.
QStrList QImage::outputFormats () [static]
Returns a list of image formats that are supported for image output.
See also QImage::outputFormatList().
Example: showimg/showimg.cpp.
QRgb QImage::pixel ( int x, int y ) const
Returns the actual color of the pixel at the given coordinates.
If (x, y) is not on the image, the results
are undefined.
See also setPixel(), qRed(), qGreen() and qBlue().
Example: qmag/qmag.cpp.
int QImage::pixelIndex ( int x, int y ) const
Returns the pixel index at the given coordinates.
If (x, y) is not valid, or if
the image is not a paletted image (depth() > 8), the results
are undefined.
QRect QImage::rect () const
Returns the enclosing rectangle (0,0,width(),height()) of the image.
See also width(), height() and size().
void QImage::reset ()
Resets all image parameters and deallocates the image data.
Example: qtimage/qtimage.cpp.
bool QImage::save ( const QString & fileName, const char * format, int quality = -1 ) const
Saves the image to the file fileName, using the image file format format and a quality factor quality. quality must be in the range
[0,100] or -1. Specify 0 to obtain small compressed files, 100 for
large uncompressed files, and -1 (the default) to use the default
settings. Returns TRUE if successful or FALSE if the image could not be
saved.
See also load(), loadFromData(), imageFormat(), QPixmap::save() and QImageIO.
QImage QImage::scale ( int w, int h, ScaleMode mode = ScaleFree ) const
Returns scaled a copy of the image. The returned image has a size
of w by h pixels if mode is ScaleFree. The modes ScaleMin and
ScaleMax preserve the ratio of the image: if mode is ScaleMin, the
returned image is guaranteed to fit into the rectangle specified by w and
h (it is a big as possible within the constraints); if mode is
ScaleMax, the returned image fits at least into the specified rectangle (it
is a small as possible within the constraints).
If either the width w or the height h is 0 or negative, this function
returns a null image.
This function uses a quite simple algorithm for doing this task; if you need
a better quality, use smoothScale() instead.
See also scaleWidth(), scaleHeight(), smoothScale() and xForm().
QImage QImage::scale ( const QSize & s, ScaleMode mode = ScaleFree ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
The wished size of the image is s.
QImage QImage::scaleHeight ( int h ) const
Returns a scaled copy of the image. The returned image has a height
of h pixels. This function automatically calculates the width of the
image so that the ratio of the image is preserved.
If the height h is 0 or negative, this function returns a null image.
QImage img( qtlogo_xpm );
QPixmap pix = img.scaleHeight( table.rowHeight(3) );
(Code taken from the table/small-table-demo/main.cpp example.)
See also scale(), scaleWidth(), smoothScale() and xForm().
Example: table/small-table-demo/main.cpp.
QImage QImage::scaleWidth ( int w ) const
Returns scaled a copy of the image. The returned image has a width
of w pixels. This function automatically calculates the height of the
image so that the ratio of the image is preserved.
If the width w is 0 or negative, this function returns a null image.
See also scale(), scaleHeight(), smoothScale() and xForm().
uchar * QImage::scanLine ( int i ) const
Returns a pointer to the pixel data at the ith scanline.
The scanline data is aligned on a 32-bit boundary.
Warning: If you are accessing 32-bpp image data, cast the returned
pointer to QRgb* (QRgb has a 32-bit size) and use it to read/write
the pixel value. You cannot use the uchar* pointer directly, because
the pixel format depends on the byte order on the underlying
platform. Hint: use qRed() and friends (qcolor.h)
to access the pixels.
Warning: If you are accessing 16-bpp image data, you have to handle
endianness yourself for now.
See also bits().
Example: desktop/desktop.cpp.
void QImage::setAlphaBuffer ( bool enable )
Enables alpha buffer mode if enable is TRUE, otherwise disables it.
The default setting is disabled.
An 8-bpp image has 8-bit pixels. A pixel is an index into the color table, which contains 32-bit color values.
In a 32-bpp image, the 32-bit pixels are the color values.
This 32-bit value is encoded as follows: The lower 24 bits are used for
the red, green, and blue components. The upper 8 bits contain the alpha
component.
The alpha component specifies the transparency of a pixel. 0 means
completely transparent and 255 means opaque. The alpha component is
ignored if you do not enable alpha buffer mode.
The alpha buffer is used to set a mask when a QImage is translated to a
QPixmap.
See also hasAlphaBuffer() and createAlphaMask().
void QImage::setColor ( int i, QRgb c )
Sets a color in the color table at index i to c.
A color value is an RGB triplet. Use the qRgb function (defined in qcolor.h)
to make RGB triplets.
See also color().
Examples: desktop/desktop.cpp and themes/wood.cpp.
void QImage::setDotsPerMeterX ( int x )
Sets the value returned by dotsPerMeterX() to x.
void QImage::setDotsPerMeterY ( int y )
Sets the value returned by dotsPerMeterY() to y.
void QImage::setNumColors ( int numColors )
Resizes the color table to numColors colors.
If the color table is expanded, then all new colors will be set to black
(RGB 0,0,0).
See also color() and setColor().
void QImage::setOffset ( const QPoint & p )
Sets the value returned by offset() to p.
void QImage::setPixel ( int x, int y, uint index_or_rgb )
Sets the pixel index or color at the given coordinates.
If (x, y) is not valid, or if
the image is a paletted image (depth() <= 8) and index_or_rgb
>= numColors(), the results are undefined.
See also qRgb() and qRgba().
void QImage::setText ( const char * key, const char * lang, const QString & s )
Records s for the keyword key. The key should be a portable
keyword recognizable by other software - some suggested values can
be found in
the PNG specification. s can be any text. lang should
specify the language code (see
RFC 1766) or 0.
Note that no QImageIO handlers currently read or write this
data. In an upcoming Qt version, PNG I/O will do so.
QSize QImage::size () const
Returns the size of the image.
See also width(), height() and rect().
QImage QImage::smoothScale ( int w, int h, ScaleMode mode = ScaleFree ) const
Returns smoothly scaled a copy of the image. The returned image has a size
of w by h pixels if mode is ScaleFree. The modes ScaleMin and
ScaleMax preserve the ratio of the image: if mode is ScaleMin, the
returned image is guaranteed to fit into the rectangle specified by w and
h (it is a big as possible within the constraints); if mode is
ScaleMax, the returned image fits at least into the specified rectangle (it
is a small as possible within the constraints).
For 32-bpp images and 1-bpp/8-bpp color images the result will be 32-bpp,
whereas all-gray images (including black-and-white
1-bpp) will produce 8-bit grayscale images with
the palette spanning 256 grays from black to white.
This function uses code based on pnmscale.c by Jef Poskanzer.
pnmscale.c - read a portable anymap and scale it
Copyright (C) 1989, 1991 by Jef Poskanzer.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation. This software is provided "as is" without express or
implied warranty.
See also scale() and mirror().
Example: themes/metal.cpp.
QImage QImage::smoothScale ( const QSize & s, ScaleMode mode = ScaleFree ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
The wished size of the image is s.
QImage QImage::swapRGB () const
Returns a QImage in which the values of the red and blue components of
all pixels have been swapped, effectively converting an RGB image to
a BGR image. The original QImage is left unchanged.
Endian QImage::systemBitOrder () [static]
Determines the bit order of the display hardware.
Returns QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first).
Endian QImage::systemByteOrder () [static]
Determines the host computer byte order.
Returns QImage::LittleEndian (LSB first) or QImage::BigEndian (MSB first).
QString QImage::text ( const char * key, const char * lang = 0 ) const
Returns the string recorded for the keyword key in language lang,
or in a default language if lang is 0.
QString QImage::text ( const QImageTextKeyLang & kl ) const
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the string recorded for the keyword and language kl.
QStringList QImage::textKeys () const
Returns the keywords for which some texts are recorded.
See also textList(), text(), setText() and textLanguages().
QStringList QImage::textLanguages () const
Returns the language identifiers for which some texts are recorded.
See also textList(), text(), setText() and textKeys().
QValueList<QImageTextKeyLang> QImage::textList () const
Returns a list of QImageTextKeyLang objects that enumerate
all the texts key/language pairs set by setText() for this image.
bool QImage::valid ( int x, int y ) const
Tests if the ( x, y ) is a valid coordinate in the image.
Example: qmag/qmag.cpp.
int QImage::width () const
Returns the width of the image.
See also height(), size() and rect().
Example: opengl/texture/gltexobj.cpp.
QImage QImage::xForm ( const QWMatrix & matrix ) const
Returns a copy of the image that is transformed using matrix.
The transformation matrix matrix is internally adjusted to compensate for
unwanted translation, i.e., xForm() returns the smallest image containing all
transformed points of the original image.
See also scale(), QPixmap::xForm(), QPixmap::trueMatrix() and QWMatrix.
Related Functions
Writes the image image to the stream s as a PNG image.
See also QImage::save() and Format of the QDataStream operators.
Reads an image from the stream s and stores it in image.
See also QImage::load() and Format of the QDataStream operators.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit,
copyright © 1995-2001
Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks
| Qt version 3.0.0-beta1-beta1
|