You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
789 lines
37 KiB
789 lines
37 KiB
'\" t
|
|
.TH TQPixmap 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
TQPixmap \- Off-screen, pixel-based paint device
|
|
.SH SYNOPSIS
|
|
\fC#include <tqpixmap.h>\fR
|
|
.PP
|
|
Inherits TQPaintDevice and Qt.
|
|
.PP
|
|
Inherited by TQBitmap and TQCanvasPixmap.
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "enum \fBColorMode\fR { Auto, Color, Mono }"
|
|
.br
|
|
.ti -1c
|
|
.BI "enum \fBOptimization\fR { DefaultOptim, NoOptim, MemoryOptim = NoOptim, NormalOptim, BestOptim }"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const TQImage & image )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( int w, int h, int depth = -1, Optimization optimization = DefaultOptim )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const TQSize & size, int depth = -1, Optimization optimization = DefaultOptim )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const TQString & fileName, const char * format = 0, ColorMode mode = Auto )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const TQString & fileName, const char * format, int conversion_flags )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const char * xpm[] )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const TQByteArray & img_data )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( const TQPixmap & pixmap )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fB~TQPixmap\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQPixmap & \fBoperator=\fR ( const TQPixmap & pixmap )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQPixmap & \fBoperator=\fR ( const TQImage & image )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisNull\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBwidth\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBheight\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQSize \fBsize\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQRect \fBrect\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBdepth\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBfill\fR ( const TQColor & fillColor = TQt::white )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBfill\fR ( const TQWidget * widget, int xofs, int yofs )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBfill\fR ( const TQWidget * widget, const TQPoint & ofs )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBresize\fR ( int w, int h )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBresize\fR ( const TQSize & size )"
|
|
.br
|
|
.ti -1c
|
|
.BI "const TQBitmap * \fBmask\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetMask\fR ( const TQBitmap & newmask )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBselfMask\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBhasAlpha\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBhasAlphaChannel\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQBitmap \fBcreateHeuristicMask\fR ( bool clipTight = TRUE ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQPixmap \fBxForm\fR ( const TQWMatrix & matrix ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQImage \fBconvertToImage\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBconvertFromImage\fR ( const TQImage & image, ColorMode mode = Auto )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBconvertFromImage\fR ( const TQImage & img, int conversion_flags )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBload\fR ( const TQString & fileName, const char * format = 0, ColorMode mode = Auto )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBload\fR ( const TQString & fileName, const char * format, int conversion_flags )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBloadFromData\fR ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBloadFromData\fR ( const uchar * buf, uint len, const char * format, int conversion_flags )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBloadFromData\fR ( const TQByteArray & buf, const char * format = 0, int conversion_flags = 0 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBsave\fR ( const TQString & fileName, const char * format, int quality = -1 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBsave\fR ( TQIODevice * device, const char * format, int quality = -1 ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBserialNumber\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "Optimization \fBoptimization\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetOptimization\fR ( Optimization optimization )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBdetach\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisTQBitmap\fR () const"
|
|
.br
|
|
.in -1c
|
|
.SS "Static Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "int \fBdefaultDepth\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQPixmap \fBfromMimeSource\fR ( const TQString & abs_name )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQPixmap \fBgrabWindow\fR ( WId window, int x = 0, int y = 0, int w = -1, int h = -1 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQPixmap \fBgrabWidget\fR ( TQWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQWMatrix \fBtrueMatrix\fR ( const TQWMatrix & matrix, int w, int h )"
|
|
.br
|
|
.ti -1c
|
|
.BI "const char * \fBimageFormat\fR ( const TQString & fileName )"
|
|
.br
|
|
.ti -1c
|
|
.BI "Optimization \fBdefaultOptimization\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetDefaultOptimization\fR ( Optimization optimization )"
|
|
.br
|
|
.in -1c
|
|
.SS "Protected Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBTQPixmap\fR ( int w, int h, const uchar * bits, bool isXbitmap )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual int \fBmetric\fR ( int m ) const"
|
|
.br
|
|
.in -1c
|
|
.SH RELATED FUNCTION DOCUMENTATION
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "TQDataStream & \fBoperator<<\fR ( TQDataStream & s, const TQPixmap & pixmap )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQDataStream & \fBoperator>>\fR ( TQDataStream & s, TQPixmap & pixmap )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBcopyBlt\fR ( TQPixmap * dst, int dx, int dy, const TQPixmap * src, int sx, int sy, int sw, int sh )"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The TQPixmap class is an off-screen, pixel-based paint device.
|
|
.PP
|
|
TQPixmap is one of the two classes TQt provides for dealing with images; the other is TQImage. TQPixmap is designed and optimized for drawing; TQImage is designed and optimized for I/O and for direct pixel access/manipulation. There are (slow) functions to convert between TQImage and TQPixmap: convertToImage() and convertFromImage().
|
|
.PP
|
|
One common use of the TQPixmap class is to enable smooth updating of widgets. Whenever something complex needs to be drawn, you can use a pixmap to obtain flicker-free drawing, like this:
|
|
.PP
|
|
<ol type=1>
|
|
.IP 1
|
|
Create a pixmap with the same size as the widget.
|
|
.IP 2
|
|
Fill the pixmap with the widget background color.
|
|
.IP 3
|
|
Paint the pixmap.
|
|
.IP 4
|
|
bitBlt() the pixmap contents onto the widget.
|
|
.PP
|
|
Pixel data in a pixmap is internal and is managed by the underlying window system. Pixels can be accessed only through TQPainter functions, through bitBlt(), and by converting the TQPixmap to a TQImage.
|
|
.PP
|
|
You can easily display a TQPixmap on the screen using QLabel::setPixmap(). For example, all the QButton subclasses support pixmap use.
|
|
.PP
|
|
The TQPixmap class uses copy-on-write, so it is practical to pass TQPixmap objects by value.
|
|
.PP
|
|
You can retrieve the width(), height(), depth() and size() of a pixmap. The enclosing rectangle is given by rect(). Pixmaps can be filled with fill() and resized with resize(). You can create and set a mask with createHeuristicMask() and setMask(). Use selfMask() to see if the pixmap is identical to its mask.
|
|
.PP
|
|
In addition to loading a pixmap from file using load() you can also loadFromData(). You can control optimization with setOptimization() and obtain a transformed version of the pixmap using xForm()
|
|
.PP
|
|
Note regarding Windows 95 and 98: on Windows 9x the system crashes if you create more than about 1000 pixmaps, independent of the size of the pixmaps or installed RAM. Windows NT-systems (including 2000, XP and following versions) do not have the same limitation, but depending on the graphics equipment the system will fail to allocate pixmap objects at some point (due to system running out of GDI resources).
|
|
.PP
|
|
Qt tries to work around the resource limitation. If you set the pixmap optimization to TQPixmap::MemoryOptim and the width of your pixmap is less than or equal to 128 pixels, TQt stores the pixmap in a way that is very memory-efficient when there are many pixmaps.
|
|
.PP
|
|
If your application uses dozens or hundreds of pixmaps (for example on tool bar buttons and in popup menus), and you plan to run it on Windows 95 or Windows 98, we recommend using code like this:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQPixmap::setDefaultOptimization( TQPixmap::MemoryOptim );
|
|
.br
|
|
while ( ... ) {
|
|
.br
|
|
// load tool bar pixmaps etc.
|
|
.br
|
|
TQPixmap *pixmap = new TQPixmap(fileName);
|
|
.br
|
|
}
|
|
.br
|
|
TQPixmap::setDefaultOptimization( TQPixmap::NormalOptim );
|
|
.br
|
|
.fi
|
|
.PP
|
|
In general it is recommended to make as much use of TQPixmap's implicit sharing and the TQPixmapCache as possible.
|
|
.PP
|
|
See also TQBitmap, TQImage, TQImageIO, Shared Classes, Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.
|
|
.SS "Member Type Documentation"
|
|
.SH "TQPixmap::ColorMode"
|
|
This enum type defines the color modes that exist for converting TQImage objects to TQPixmap.
|
|
.TP
|
|
\fCTQPixmap::Auto\fR - Select Color or Mono on a case-by-case basis.
|
|
.TP
|
|
\fCTQPixmap::Color\fR - Always create colored pixmaps.
|
|
.TP
|
|
\fCTQPixmap::Mono\fR - Always create bitmaps.
|
|
.SH "TQPixmap::Optimization"
|
|
TQPixmap has the choice of optimizing for speed or memory in a few places; the best choice varies from pixmap to pixmap but can generally be derived heuristically. This enum type defines a number of optimization modes that you can set for any pixmap to tweak the speed/memory tradeoffs:
|
|
.TP
|
|
\fCTQPixmap::DefaultOptim\fR - Whatever TQPixmap::defaultOptimization() returns. A pixmap with this optimization will have whatever the current default optimization is. If the default optimization is changed using setDefaultOptimization(), then this will not effect any pixmaps that have already been created.
|
|
.TP
|
|
\fCTQPixmap::NoOptim\fR - No optimization (currently the same as MemoryOptim).
|
|
.TP
|
|
\fCTQPixmap::MemoryOptim\fR - Optimize for minimal memory use on Windows 9x and X11 systems.
|
|
.TP
|
|
\fCTQPixmap::NormalOptim\fR - Optimize for typical usage. Often uses more memory than MemoryOptim, and is often faster.
|
|
.TP
|
|
\fCTQPixmap::BestOptim\fR - Optimize for pixmaps that are drawn very often and where performance is critical. Generally uses more memory than NormalOptim and may provide a little more speed.
|
|
.PP
|
|
We recommend using DefaultOptim.
|
|
.PP
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "TQPixmap::TQPixmap ()"
|
|
Constructs a null pixmap.
|
|
.PP
|
|
See also isNull().
|
|
.SH "TQPixmap::TQPixmap ( const TQImage & image )"
|
|
Constructs a pixmap from the TQImage \fIimage\fR.
|
|
.PP
|
|
See also convertFromImage().
|
|
.SH "TQPixmap::TQPixmap ( int w, int h, int depth = -1, Optimization optimization = DefaultOptim )"
|
|
Constructs a pixmap with \fIw\fR width, \fIh\fR height and \fIdepth\fR bits per pixel. The pixmap is optimized in accordance with the \fIoptimization\fR value.
|
|
.PP
|
|
The contents of the pixmap is uninitialized.
|
|
.PP
|
|
The \fIdepth\fR can be either 1 (monochrome) or the depth of the current video mode. If \fIdepth\fR is negative, then the hardware depth of the current video mode will be used.
|
|
.PP
|
|
If either \fIw\fR or \fIh\fR is zero, a null pixmap is constructed.
|
|
.PP
|
|
See also isNull() and TQPixmap::Optimization.
|
|
.SH "TQPixmap::TQPixmap ( const TQSize & size, int depth = -1, Optimization optimization = DefaultOptim )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Constructs a pixmap of size \fIsize\fR, \fIdepth\fR bits per pixel, optimized in accordance with the \fIoptimization\fR value.
|
|
.SH "TQPixmap::TQPixmap ( const TQString & fileName, const char * format = 0, ColorMode mode = Auto )"
|
|
Constructs a pixmap from the file \fIfileName\fR. If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap.
|
|
.PP
|
|
The \fIfileName\fR, \fIformat\fR and \fImode\fR parameters are passed on to load(). This means that the data in \fIfileName\fR is not compiled into the binary. If \fIfileName\fR contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
|
|
.PP
|
|
See also TQPixmap::ColorMode, isNull(), load(), loadFromData(), save(), and imageFormat().
|
|
.SH "TQPixmap::TQPixmap ( const TQString & fileName, const char * format, int conversion_flags )"
|
|
Constructs a pixmap from the file \fIfileName\fR. If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap.
|
|
.PP
|
|
The \fIfileName\fR, \fIformat\fR and \fIconversion_flags\fR parameters are passed on to load(). This means that the data in \fIfileName\fR is not compiled into the binary. If \fIfileName\fR contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
|
|
.PP
|
|
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 \fIconversion_flags\fR to specify how you'd prefer this to happen.
|
|
.PP
|
|
See also TQt::ImageConversionFlags, isNull(), load(), loadFromData(), save(), and imageFormat().
|
|
.SH "TQPixmap::TQPixmap ( const char * xpm[] )"
|
|
Constructs a pixmap from \fIxpm\fR, which must be a valid XPM image.
|
|
.PP
|
|
Errors are silently ignored.
|
|
.PP
|
|
Note that it's possible to squeeze the XPM variable a little bit by using an unusual declaration:
|
|
.PP
|
|
.nf
|
|
.br
|
|
static const char * const start_xpm[]={
|
|
.br
|
|
"16 15 8 1",
|
|
.br
|
|
"a c #cec6bd",
|
|
.br
|
|
....
|
|
.br
|
|
.fi
|
|
.PP
|
|
The extra \fCconst\fR makes the entire definition read-only, which is slightly more efficient (for example, when the code is in a shared library) and ROMable when the application is to be stored in ROM.
|
|
.PP
|
|
In order to use that sort of declaration you must cast the variable back to \fCconst char **\fR when you create the TQPixmap.
|
|
.SH "TQPixmap::TQPixmap ( const TQByteArray & img_data )"
|
|
Constructs a pixmaps by loading from \fIimg_data\fR. The data can be in any image format supported by Qt.
|
|
.PP
|
|
See also loadFromData().
|
|
.SH "TQPixmap::TQPixmap ( const TQPixmap & pixmap )"
|
|
Constructs a pixmap that is a copy of \fIpixmap\fR.
|
|
.SH "TQPixmap::TQPixmap ( int w, int h, const uchar * bits, bool isXbitmap )\fC [protected]\fR"
|
|
Constructs a monochrome pixmap, with width \fIw\fR and height \fIh\fR, that is initialized with the data in \fIbits\fR. The \fIisXbitmap\fR indicates whether the data is an X bitmap and defaults to FALSE. This constructor is protected and used by the TQBitmap class.
|
|
.SH "TQPixmap::~TQPixmap ()"
|
|
Destroys the pixmap.
|
|
.SH "bool TQPixmap::convertFromImage ( const TQImage & img, int conversion_flags )"
|
|
Converts image \fIimg\fR and sets this pixmap. Returns TRUE if successful; otherwise returns FALSE.
|
|
.PP
|
|
The \fIconversion_flags\fR argument is a bitwise-OR of the TQt::ImageConversionFlags. Passing 0 for \fIconversion_flags\fR sets all the default options.
|
|
.PP
|
|
Note that even though a TQPixmap with depth 1 behaves much like a TQBitmap, isTQBitmap() returns FALSE.
|
|
.PP
|
|
If a pixmap with depth 1 is painted with color0 and color1 and converted to an image, the pixels painted with color0 will produce pixel index 0 in the image and those painted with color1 will produce pixel index 1.
|
|
.PP
|
|
See also convertToImage(), isTQBitmap(), TQImage::convertDepth(), defaultDepth(), and TQImage::hasAlphaBuffer().
|
|
.PP
|
|
Examples:
|
|
.)l canvas/canvas.cpp and themes/wood.cpp.
|
|
.SH "bool TQPixmap::convertFromImage ( const TQImage & image, ColorMode mode = Auto )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Converts \fIimage\fR and sets this pixmap using color mode \fImode\fR. Returns TRUE if successful; otherwise returns FALSE.
|
|
.PP
|
|
See also TQPixmap::ColorMode.
|
|
.SH "TQImage TQPixmap::convertToImage () const"
|
|
Converts the pixmap to a TQImage. Returns a null image if it fails.
|
|
.PP
|
|
If the pixmap has 1-bit depth, the returned image will also be 1 bit deep. If the pixmap has 2- to 8-bit depth, the returned image has 8-bit depth. If the pixmap has greater than 8-bit depth, the returned image has 32-bit depth.
|
|
.PP
|
|
Note that for the moment, alpha masks on monochrome images are ignored.
|
|
.PP
|
|
See also convertFromImage().
|
|
.PP
|
|
Example: qmag/qmag.cpp.
|
|
.SH "TQBitmap TQPixmap::createHeuristicMask ( bool clipTight = TRUE ) const"
|
|
Creates and returns a heuristic mask for this pixmap. It works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges.
|
|
.PP
|
|
The mask may not be perfect but it should be reasonable, so you can do things such as the following:
|
|
.PP
|
|
.nf
|
|
.br
|
|
pm->setMask( pm->createHeuristicMask() );
|
|
.br
|
|
.fi
|
|
.PP
|
|
This function is slow because it involves transformation to a TQImage, non-trivial computations and a transformation back to a TQBitmap.
|
|
.PP
|
|
If \fIclipTight\fR is TRUE the mask is just large enough to cover the pixels; otherwise, the mask is larger than the data pixels.
|
|
.PP
|
|
See also TQImage::createHeuristicMask().
|
|
.SH "int TQPixmap::defaultDepth ()\fC [static]\fR"
|
|
Returns the default pixmap depth, i.e. the depth a pixmap gets if -1 is specified.
|
|
.PP
|
|
See also depth().
|
|
.SH "Optimization TQPixmap::defaultOptimization ()\fC [static]\fR"
|
|
Returns the default pixmap optimization setting.
|
|
.PP
|
|
See also setDefaultOptimization(), setOptimization(), and optimization().
|
|
.SH "int TQPixmap::depth () const"
|
|
Returns the depth of the pixmap.
|
|
.PP
|
|
The pixmap depth is also called bits per pixel (bpp) or bit planes of a pixmap. A null pixmap has depth 0.
|
|
.PP
|
|
See also defaultDepth(), isNull(), and TQImage::convertDepth().
|
|
.SH "void TQPixmap::detach ()\fC [virtual]\fR"
|
|
This is a special-purpose function that detaches the pixmap from shared pixmap data.
|
|
.PP
|
|
A pixmap is automatically detached by TQt whenever its contents is about to change. This is done in all TQPixmap member functions that modify the pixmap (fill(), resize(), convertFromImage(), load(), etc.), in bitBlt() for the destination pixmap and in TQPainter::begin() on a pixmap.
|
|
.PP
|
|
It is possible to modify a pixmap without letting TQt know. You can first obtain the system-dependent handle() and then call system-specific functions (for instance, BitBlt under Windows) that modify the pixmap contents. In such cases, you can call detach() to cut the pixmap loose from other pixmaps that share data with this one.
|
|
.PP
|
|
detach() returns immediately if there is just a single reference or if the pixmap has not been initialized yet.
|
|
.SH "void TQPixmap::fill ( const TQColor & fillColor = TQt::white )"
|
|
Fills the pixmap with the color \fIfillColor\fR.
|
|
.PP
|
|
Examples:
|
|
.)l chart/setdataform.cpp, desktop/desktop.cpp, grapher/grapher.cpp, hello/hello.cpp, t10/cannon.cpp, themes/metal.cpp, and xform/xform.cpp.
|
|
.SH "void TQPixmap::fill ( const TQWidget * widget, int xofs, int yofs )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Fills the pixmap with the \fIwidget\fR's background color or pixmap. If the background is empty, nothing is done. \fIxofs\fR, \fIyofs\fR is an offset in the widget.
|
|
.SH "void TQPixmap::fill ( const TQWidget * widget, const TQPoint & ofs )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Fills the pixmap with the \fIwidget\fR's background color or pixmap. If the background is empty, nothing is done.
|
|
.PP
|
|
The \fIofs\fR point is an offset in the widget.
|
|
.PP
|
|
The point \fIofs\fR is a point in the widget's coordinate system. The pixmap's top-left pixel will be mapped to the point \fIofs\fR in the widget. This is significant if the widget has a background pixmap; otherwise the pixmap will simply be filled with the background color of the widget.
|
|
.PP
|
|
Example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
void CuteWidget::paintEvent( TQPaintEvent *e )
|
|
.br
|
|
{
|
|
.br
|
|
TQRect ur = e->rect(); // rectangle to update
|
|
.br
|
|
TQPixmap pix( ur.size() ); // Pixmap for double-buffering
|
|
.br
|
|
pix.fill( this, ur.topLeft() ); // fill with widget background
|
|
.br
|
|
.br
|
|
TQPainter p( &pix );
|
|
.br
|
|
p.translate( -ur.x(), -ur.y() ); // use widget coordinate system
|
|
.br
|
|
// when drawing on pixmap
|
|
.br
|
|
// ... draw on pixmap ...
|
|
.br
|
|
.br
|
|
p.end();
|
|
.br
|
|
.br
|
|
bitBlt( this, ur.topLeft(), &pix );
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
.SH "TQPixmap TQPixmap::fromMimeSource ( const TQString & abs_name )\fC [static]\fR"
|
|
Convenience function. Gets the data associated with the absolute name \fIabs_name\fR from the default mime source factory and decodes it to a pixmap.
|
|
.PP
|
|
See also TQMimeSourceFactory, TQImage::fromMimeSource(), and TQImageDrag::decode().
|
|
.PP
|
|
Example: textedit/textedit.cpp.
|
|
.SH "TQPixmap TQPixmap::grabWidget ( TQWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 )\fC [static]\fR"
|
|
Creates a pixmap and paints \fIwidget\fR in it.
|
|
.PP
|
|
If the \fIwidget\fR has any children, then they are also painted in the appropriate positions.
|
|
.PP
|
|
If you specify \fIx\fR, \fIy\fR, \fIw\fR or \fIh\fR, only the rectangle you specify is painted. The defaults are 0, 0 (top-left corner) and -1,-1 (which means the entire widget).
|
|
.PP
|
|
(If \fIw\fR is negative, the function copies everything to the right border of the window. If \fIh\fR is negative, the function copies everything to the bottom of the window.)
|
|
.PP
|
|
If \fIwidget\fR is 0, or if the rectangle defined by \fIx\fR, \fIy\fR, the modified \fIw\fR and the modified \fIh\fR does not overlap the \fIwidget\fR->rect(), this function will return a null TQPixmap.
|
|
.PP
|
|
This function actually asks \fIwidget\fR to paint itself (and its children to paint themselves). TQPixmap::grabWindow() grabs pixels off the screen, which is a bit faster and picks up \fIexactly\fR what's on-screen. This function works by calling paintEvent() with painter redirection turned on. If there are overlaying windows, grabWindow() will see them, but not this function.
|
|
.PP
|
|
If there is overlap, it returns a pixmap of the size you want, containing a rendering of \fIwidget\fR. If the rectangle you ask for is a superset of \fIwidget\fR, the areas outside \fIwidget\fR are covered with the widget's background.
|
|
.PP
|
|
If an error occurs when trying to grab the widget, such as the size of the widget being too large to fit in memory, an isNull() pixmap is returned.
|
|
.PP
|
|
See also grabWindow(), TQPainter::redirect(), and TQWidget::paintEvent().
|
|
.SH "TQPixmap TQPixmap::grabWindow ( WId window, int x = 0, int y = 0, int w = -1, int h = -1 )\fC [static]\fR"
|
|
Grabs the contents of the window \fIwindow\fR and makes a pixmap out of it. Returns the pixmap.
|
|
.PP
|
|
The arguments \fI(x, y)\fR specify the offset in the window, whereas \fI(w, h)\fR specify the width and height of the area to be copied.
|
|
.PP
|
|
If \fIw\fR is negative, the function copies everything to the right border of the window. If \fIh\fR is negative, the function copies everything to the bottom of the window.
|
|
.PP
|
|
Note that grabWindow() grabs pixels from the screen, not from the window. If there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too.
|
|
.PP
|
|
Note also that the mouse cursor is generally not grabbed.
|
|
.PP
|
|
The reason we use a window identifier and not a TQWidget is to enable grabbing of windows that are not part of the application, window system frames, and so on.
|
|
.PP
|
|
\fBWarning:\fR Grabbing an area outside the screen is not safe in general. This depends on the underlying window system.
|
|
.PP
|
|
\fBWarning:\fR X11 only: If \fIwindow\fR is not the same depth as the root window and another window partially or entirely obscures the one you grab, you will \fInot\fR get pixels from the overlying window. The contests of the obscured areas in the pixmap are undefined and uninitialized.
|
|
.PP
|
|
See also grabWidget().
|
|
.PP
|
|
Example: qmag/qmag.cpp.
|
|
.SH "bool TQPixmap::hasAlpha () const"
|
|
Returns TRUE this pixmap has an alpha channel or a mask.
|
|
.PP
|
|
See also hasAlphaChannel() and mask().
|
|
.SH "bool TQPixmap::hasAlphaChannel () const"
|
|
Returns TRUE if the pixmap has an alpha channel; otherwise it returns FALSE.
|
|
.PP
|
|
NOTE: If the pixmap has a mask but not alpha channel, this function returns FALSE.
|
|
.PP
|
|
See also hasAlpha() and mask().
|
|
.SH "int TQPixmap::height () const"
|
|
Returns the height of the pixmap.
|
|
.PP
|
|
See also width(), size(), and rect().
|
|
.PP
|
|
Examples:
|
|
.)l desktop/desktop.cpp, movies/main.cpp, scribble/scribble.cpp, scrollview/scrollview.cpp, t10/cannon.cpp, and xform/xform.cpp.
|
|
.SH "const char * TQPixmap::imageFormat ( const TQString & fileName )\fC [static]\fR"
|
|
Returns a string that specifies the image format of the file \fIfileName\fR, or 0 if the file cannot be read or if the format cannot be recognized.
|
|
.PP
|
|
The TQImageIO documentation lists the supported image formats.
|
|
.PP
|
|
See also load() and save().
|
|
.SH "bool TQPixmap::isNull () const"
|
|
Returns TRUE if this is a null pixmap; otherwise returns FALSE.
|
|
.PP
|
|
A null pixmap has zero width, zero height and no contents. You cannot draw in a null pixmap or bitBlt() anything to it.
|
|
.PP
|
|
Resizing an existing pixmap to (0, 0) makes a pixmap into a null pixmap.
|
|
.PP
|
|
See also resize().
|
|
.PP
|
|
Examples:
|
|
.)l movies/main.cpp, tqdir/tqdir.cpp, qmag/qmag.cpp, and scrollview/scrollview.cpp.
|
|
.SH "bool TQPixmap::isTQBitmap () const"
|
|
Returns TRUE if this is a TQBitmap; otherwise returns FALSE.
|
|
.SH "bool TQPixmap::load ( const TQString & fileName, const char * format, int conversion_flags )"
|
|
Loads a pixmap from the file \fIfileName\fR at runtime. Returns TRUE if successful; otherwise returns FALSE.
|
|
.PP
|
|
If \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format.
|
|
.PP
|
|
See the convertFromImage() documentation for a description of the \fIconversion_flags\fR argument.
|
|
.PP
|
|
The TQImageIO documentation lists the supported image formats and explains how to add extra formats.
|
|
.PP
|
|
See also loadFromData(), save(), imageFormat(), TQImage::load(), and TQImageIO.
|
|
.PP
|
|
Examples:
|
|
.)l picture/picture.cpp, scrollview/scrollview.cpp, and xform/xform.cpp.
|
|
.SH "bool TQPixmap::load ( const TQString & fileName, const char * format = 0, ColorMode mode = Auto )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Loads a pixmap from the file \fIfileName\fR at runtime.
|
|
.PP
|
|
If \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format.
|
|
.PP
|
|
The \fImode\fR is used to specify the color mode of the pixmap.
|
|
.PP
|
|
See also TQPixmap::ColorMode.
|
|
.SH "bool TQPixmap::loadFromData ( const uchar * buf, uint len, const char * format, int conversion_flags )"
|
|
Loads a pixmap from the binary data in \fIbuf\fR (\fIlen\fR bytes). Returns TRUE if successful; otherwise returns FALSE.
|
|
.PP
|
|
If \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format.
|
|
.PP
|
|
See the convertFromImage() documentation for a description of the \fIconversion_flags\fR argument.
|
|
.PP
|
|
The TQImageIO documentation lists the supported image formats and explains how to add extra formats.
|
|
.PP
|
|
See also load(), save(), imageFormat(), TQImage::loadFromData(), and TQImageIO.
|
|
.SH "bool TQPixmap::loadFromData ( const uchar * buf, uint len, const char * format = 0, ColorMode mode = Auto )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Loads a pixmap from the binary data in \fIbuf\fR (\fIlen\fR bytes) using color mode \fImode\fR. Returns TRUE if successful; otherwise returns FALSE.
|
|
.PP
|
|
If \fIformat\fR is specified, the loader attempts to read the pixmap using the specified format. If \fIformat\fR is not specified (default), the loader reads a few bytes from the header to guess the file's format.
|
|
.PP
|
|
See also TQPixmap::ColorMode.
|
|
.SH "bool TQPixmap::loadFromData ( const TQByteArray & buf, const char * format = 0, int conversion_flags = 0 )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.SH "const TQBitmap * TQPixmap::mask () const"
|
|
Returns the mask bitmap, or 0 if no mask has been set.
|
|
.PP
|
|
See also setMask(), TQBitmap, and hasAlpha().
|
|
.SH "int TQPixmap::metric ( int m ) const\fC [virtual protected]\fR"
|
|
Internal implementation of the virtual TQPaintDevice::metric() function.
|
|
.PP
|
|
Use the TQPaintDeviceMetrics class instead.
|
|
.PP
|
|
\fIm\fR is the metric to get.
|
|
.SH "TQPixmap & TQPixmap::operator= ( const TQPixmap & pixmap )"
|
|
Assigns the pixmap \fIpixmap\fR to this pixmap and returns a reference to this pixmap.
|
|
.SH "TQPixmap & TQPixmap::operator= ( const TQImage & image )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Converts the image \fIimage\fR to a pixmap that is assigned to this pixmap. Returns a reference to the pixmap.
|
|
.PP
|
|
See also convertFromImage().
|
|
.SH "Optimization TQPixmap::optimization () const"
|
|
Returns the optimization setting for this pixmap.
|
|
.PP
|
|
The default optimization setting is TQPixmap::NormalOptim. You can change this setting in two ways:
|
|
.TP
|
|
Call setDefaultOptimization() to set the default optimization for all new pixmaps.
|
|
.TP
|
|
Call setOptimization() to set the optimization for individual pixmaps.
|
|
.PP
|
|
See also setOptimization(), setDefaultOptimization(), and defaultOptimization().
|
|
.SH "TQRect TQPixmap::rect () const"
|
|
Returns the enclosing rectangle (0,0,width(),height()) of the pixmap.
|
|
.PP
|
|
See also width(), height(), and size().
|
|
.SH "void TQPixmap::resize ( int w, int h )"
|
|
Resizes the pixmap to \fIw\fR width and \fIh\fR height. If either \fIw\fR or \fIh\fR is 0, the pixmap becomes a null pixmap.
|
|
.PP
|
|
If both \fIw\fR and \fIh\fR are greater than 0, a valid pixmap is created. New pixels will be uninitialized (random) if the pixmap is expanded.
|
|
.PP
|
|
Examples:
|
|
.)l desktop/desktop.cpp and grapher/grapher.cpp.
|
|
.SH "void TQPixmap::resize ( const TQSize & size )"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Resizes the pixmap to size \fIsize\fR.
|
|
.SH "bool TQPixmap::save ( const TQString & fileName, const char * format, int quality = -1 ) const"
|
|
Saves the pixmap to the file \fIfileName\fR using the image file format \fIformat\fR and a quality factor \fIquality\fR. \fIquality\fR must be in the range [0,100] or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 to use the default settings. Returns TRUE if successful; otherwise returns FALSE.
|
|
.PP
|
|
See also load(), loadFromData(), imageFormat(), TQImage::save(), and TQImageIO.
|
|
.PP
|
|
Example: qmag/qmag.cpp.
|
|
.SH "bool TQPixmap::save ( TQIODevice * device, const char * format, int quality = -1 ) const"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
This function writes a TQPixmap to the TQIODevice, \fIdevice\fR. This can be used, for example, to save a pixmap directly into a TQByteArray:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQPixmap pixmap;
|
|
.br
|
|
TQByteArray ba;
|
|
.br
|
|
TQBuffer buffer( ba );
|
|
.br
|
|
buffer.open( IO_WriteOnly );
|
|
.br
|
|
pixmap.save( &buffer, "PNG" ); // writes pixmap into ba in PNG format
|
|
.br
|
|
.fi
|
|
.SH "bool TQPixmap::selfMask () const"
|
|
Returns TRUE if the pixmap's mask is identical to the pixmap itself; otherwise returns FALSE.
|
|
.PP
|
|
See also mask().
|
|
.SH "int TQPixmap::serialNumber () const"
|
|
Returns a number that uniquely identifies the contents of this TQPixmap object. This means that multiple TQPixmap objects can have the same serial number as long as they refer to the same contents.
|
|
.PP
|
|
An example of where this is useful is for caching TQPixmaps.
|
|
.PP
|
|
See also TQPixmapCache.
|
|
.SH "void TQPixmap::setDefaultOptimization ( Optimization optimization )\fC [static]\fR"
|
|
Sets the default pixmap optimization.
|
|
.PP
|
|
All \fInew\fR pixmaps that are created will use this default optimization. You may also set optimization for individual pixmaps using the setOptimization() function.
|
|
.PP
|
|
The initial default \fIoptimization\fR setting is \fCTQPixmap::Normal\fR.
|
|
.PP
|
|
See also defaultOptimization(), setOptimization(), and optimization().
|
|
.SH "void TQPixmap::setMask ( const TQBitmap & newmask )"
|
|
Sets a mask bitmap.
|
|
.PP
|
|
The \fInewmask\fR bitmap defines the clip mask for this pixmap. Every pixel in \fInewmask\fR corresponds to a pixel in this pixmap. Pixel value 1 means opaque and pixel value 0 means transparent. The mask must have the same size as this pixmap.
|
|
.PP
|
|
\fBWarning:\fR Setting the mask on a pixmap will cause any alpha channel data to be cleared. For example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQPixmap alpha( "image-with-alpha.png" );
|
|
.br
|
|
TQPixmap alphacopy = alpha;
|
|
.br
|
|
alphacopy.setMask( *alphacopy.mask() );
|
|
.br
|
|
.fi
|
|
Now, alpha and alphacopy are visually different.
|
|
.PP
|
|
Setting a null mask resets the mask.
|
|
.PP
|
|
See also mask(), createHeuristicMask(), and TQBitmap.
|
|
.SH "void TQPixmap::setOptimization ( Optimization optimization )"
|
|
Sets pixmap drawing optimization for this pixmap.
|
|
.PP
|
|
The \fIoptimization\fR setting affects pixmap operations, in particular drawing of transparent pixmaps (bitBlt() a pixmap with a mask set) and pixmap transformations (the xForm() function).
|
|
.PP
|
|
Pixmap optimization involves keeping intermediate results in a cache buffer and using the cache to speed up bitBlt() and xForm(). The cost is more memory consumption, up to twice as much as an unoptimized pixmap.
|
|
.PP
|
|
Use the setDefaultOptimization() to change the default optimization for all new pixmaps.
|
|
.PP
|
|
See also optimization(), setDefaultOptimization(), and defaultOptimization().
|
|
.PP
|
|
Example: desktop/desktop.cpp.
|
|
.SH "TQSize TQPixmap::size () const"
|
|
Returns the size of the pixmap.
|
|
.PP
|
|
See also width(), height(), and rect().
|
|
.PP
|
|
Example: movies/main.cpp.
|
|
.SH "TQWMatrix TQPixmap::trueMatrix ( const TQWMatrix & matrix, int w, int h )\fC [static]\fR"
|
|
Returns the actual matrix used for transforming a pixmap with \fIw\fR width and \fIh\fR height and matrix \fImatrix\fR.
|
|
.PP
|
|
When transforming a pixmap with xForm(), the transformation matrix is internally adjusted to compensate for unwanted translation, i.e. xForm() returns the smallest pixmap containing all transformed points of the original pixmap.
|
|
.PP
|
|
This function returns the modified matrix, which maps points correctly from the original pixmap into the new pixmap.
|
|
.PP
|
|
See also xForm() and TQWMatrix.
|
|
.SH "int TQPixmap::width () const"
|
|
Returns the width of the pixmap.
|
|
.PP
|
|
See also height(), size(), and rect().
|
|
.PP
|
|
Examples:
|
|
.)l desktop/desktop.cpp, movies/main.cpp, scribble/scribble.cpp, scrollview/scrollview.cpp, and xform/xform.cpp.
|
|
.SH "TQPixmap TQPixmap::xForm ( const TQWMatrix & matrix ) const"
|
|
Returns a copy of the pixmap that is transformed using \fImatrix\fR. The original pixmap is not changed.
|
|
.PP
|
|
The transformation \fImatrix\fR 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.
|
|
.PP
|
|
This function is slow because it involves transformation to a TQImage, non-trivial computations and a transformation back to a TQPixmap.
|
|
.PP
|
|
See also trueMatrix(), TQWMatrix, TQPainter::setWorldMatrix(), and TQImage::xForm().
|
|
.PP
|
|
Examples:
|
|
.)l desktop/desktop.cpp, fileiconview/tqfileiconview.cpp, movies/main.cpp, and qmag/qmag.cpp.
|
|
.SH RELATED FUNCTION DOCUMENTATION
|
|
.SH "void copyBlt ( TQPixmap * dst, int dx, int dy, const TQPixmap * src, int sx, int sy, int sw, int sh )"
|
|
Copies a block of pixels from \fIsrc\fR to \fIdst\fR. The alpha channel and mask data (if any) is also copied from \fIsrc\fR. NOTE: \fIsrc\fR is \fInot\fR alpha blended or masked when copied to \fIdst\fR. Use bitBlt() or TQPainter::drawPixmap() to perform alpha blending or masked drawing.
|
|
.PP
|
|
\fIsx\fR, \fIsy\fR is the top-left pixel in \fIsrc\fR (0, 0 by default), \fIdx\fR, \fIdy\fR is the top-left position in \fIdst\fR and \fIsw\fR, \\sh is the size of the copied block (all of \fIsrc\fR by default).
|
|
.PP
|
|
If \fIsrc\fR, \fIdst\fR, \fIsw\fR or \fIsh\fR is 0 (zero), copyBlt() does nothing. If \fIsw\fR or \fIsh\fR is negative, copyBlt() copies starting at \fIsx\fR (and respectively, \fIsy\fR) and ending at the right edge (and respectively, the bottom edge) of \fIsrc\fR.
|
|
.PP
|
|
copyBlt() does nothing if \fIsrc\fR and \fIdst\fR have different depths.
|
|
.SH "TQDataStream & operator<< ( TQDataStream & s, const TQPixmap & pixmap )"
|
|
Writes the pixmap \fIpixmap\fR to the stream \fIs\fR as a PNG image.
|
|
.PP
|
|
Note that writing the stream to a file will not produce a valid image file.
|
|
.PP
|
|
See also TQPixmap::save() and Format of the TQDataStream operators.
|
|
.SH "TQDataStream & operator>> ( TQDataStream & s, TQPixmap & pixmap )"
|
|
Reads a pixmap from the stream \fIs\fR into the pixmap \fIpixmap\fR.
|
|
.PP
|
|
See also TQPixmap::load() and Format of the TQDataStream operators.
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/tqpixmap.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqpixmap.3qt) and the Qt
|
|
version (3.3.8).
|