|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QPixmap
public class QPixmap
The QPixmap
class is an off-screen image representation that can be used as a paint device. Qt provides four classes for handling image data: QImage
, QPixmap
, QBitmap
and QPicture
. QImage
is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap
is designed and optimized for showing images on screen. QBitmap
is only a convenience class that inherits QPixmap
, ensuring a depth of 1. The isQBitmap()
function returns true if a QPixmap
object is really a bitmap, otherwise returns false. Finally, the QPicture
class is a paint device that records and replays QPainter
commands.
A QPixmap
can easily be displayed on the screen using QLabel
or one of QAbstractButton
's subclasses (such as QPushButton
and QToolButton
). QLabel
has a pixmap property, whereas QAbstractButton
has an icon property. And because QPixmap
is a QPaintDevice
subclass, QPainter
can be used to draw directly onto pixmaps.
In addition to the ordinary constructors, a QPixmap
can be constructed using the static grabWidget()
and grabWindow()
functions which creates a QPixmap
and paints the given widget, or window, in it.
Note that the pixel data in a pixmap is internal and is managed by the underlying window system. Pixels can only be accessed through QPainter
functions or by converting the QPixmap
to a QImage
. Depending on the system, QPixmap
is stored using a RGB32 or a premultiplied alpha format. If the image has an alpha channel, and if the system allows, the preferred format is premultiplied alpha. Note also that QPixmap
, unlike QImage
, may be hardware dependent. On X11 and Mac, a QPixmap
is stored on the server side while a QImage
is stored on the client side (on Windows, these two classes have an equivalent internal representation, i.e. both QImage
and QPixmap
are stored on the client side and don't use any GDI resources).
There are functions to convert between QImage
and QPixmap
. Typically, the QImage
class is used to load an image file, optionally manipulating the image data, before the QImage
object is converted into a QPixmap
to be shown on screen. Alternatively, if no manipulation is desired, the image file can be loaded directly into a QPixmap
. On Windows, the QPixmap
class also supports conversion between HBITMAP and QPixmap
.
QPixmap
provides a collection of functions that can be used to obtain a variety of information about the pixmap. In addition, there are several functions that enables transformation of the pixmap.
QPixmap
objects can be passed around by value since the QPixmap
class uses implicit data sharing. For more information, see the Implicit Data Sharing documentation. QPixmap
objects can also be streamed.
QPixmap
provides several ways of reading an image file: The file can be loaded when constructing the QPixmap
object, or by using the load()
or loadFromData()
functions later on. When loading an image, the file name can either refer to an actual file on disk or to one of the application's embedded resources. See The Qt Resource System overview for details on how to embed images and other resource files in the application's executable. Simply call the save()
function to save a QPixmap
object.
The complete list of supported file formats are available through the QImageReader::supportedImageFormats()
and QImageWriter::supportedImageFormats()
functions. New file formats can be added as plugins. By default, Qt supports the following formats:
BMP | Windows Bitmap | Read/write |
GIF | Graphic Interchange Format (optional) | Read |
JPG | Joint Photographic Experts Group | Read/write |
JPEG | Joint Photographic Experts Group | Read/write |
PNG | Portable Network Graphics | Read/write |
PBM | Portable Bitmap | Read |
PGM | Portable Graymap | Read |
PPM | Portable Pixmap | Read/write |
XBM | X11 Bitmap | Read/write |
XPM | X11 Pixmap | Read/write |
QPixmap
provides a collection of functions that can be used to obtain a variety of information about the pixmap: Geometry | The size() , width() and height() functions provide information about the pixmap's size. The rect() function returns the image's enclosing rectangle. |
Alpha component | The hasAlphaChannel() returns true if the pixmap has a format that respects the alpha channel, otherwise returns false, while the hasAlpha() function returns true if the pixmap has an alpha channel or a mask (otherwise false). The |
Low-level information | The depth() function returns the depth of the pixmap. The defaultDepth() function returns the default depth, i.e. the depth used by the application on the given screen. The The x11Info() function returns information about the configuration of the X display used to display the widget. The x11PictureHandle() function returns the X11 Picture handle of the pixmap for |
QPixmap
object can be converted into a QImage
using the toImage()
function. Likewise, a QImage
can be converted into a QPixmap
using the fromImage()
. If this is too expensive an operation, you can use QBitmap::fromImage()
instead. In addition, on Windows, the QPixmap
class supports conversion to and from HBitmap
: the toWinHBITMAP() function creates a HBITMAP equivalent to the QPixmap
, based on the given HBitmapFormat
, and returns the HBITMAP handle. The fromWinHBITMAP() function returns a QPixmap
that is equivalent to the given bitmap which has the specified format.Pixmap Transformations
QPixmap
supports a number of functions for creating a new pixmap that is a transformed version of the original: The createHeuristicMask()
function creates and returns a 1-bpp heuristic mask (i.e. a QBitmap
) 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. The createMaskFromColor()
function creates and returns a mask (i.e. a QBitmap
) for the pixmap based on a given color.
The scaled()
, scaledToWidth()
and scaledToHeight()
functions return scaled copies of the pixmap, while the copy()
function creates a QPixmap
that is a plain copy of the original one.
The transformed()
function returns a copy of the pixmap that is transformed with the given transformation matrix and transformation mode: Internally, the transformation matrix is adjusted to compensate for unwanted translation, i.e. transformed()
returns the smallest pixmap containing all transformed points of the original pixmap. The static trueMatrix()
function returns the actual matrix used for transforming the pixmap.
There are also functions for changing attributes of a pixmap. in-place: The fill()
function fills the entire image with the given color, the setMask()
function sets a mask bitmap, and the setAlphaChannel()
function sets the pixmap's alpha channel.
QBitmap
, QImage
, QImageReader
, and QImageWriter
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Constructor Summary | |
---|---|
QPixmap()
Constructs a null pixmap. |
|
QPixmap(int w,
int h)
Constructs a pixmap with the given width and height. |
|
QPixmap(QPixmap arg__1)
Constructs a pixmap that is a copy of the given pixmap. |
|
QPixmap(QSize arg__1)
Constructs a pixmap of the given size. |
|
QPixmap(java.lang.String fileName)
Constructs a pixmap from the given xpm data, which must be a valid XPM image. |
|
QPixmap(java.lang.String[] xpm)
|
|
QPixmap(java.lang.String fileName,
java.lang.String format)
This is an overloaded constructor provided for convenience. |
|
QPixmap(java.lang.String fileName,
java.lang.String format,
Qt.ImageConversionFlag[] flags)
Constructs a pixmap from the file with the given fileName. |
|
QPixmap(java.lang.String fileName,
java.lang.String format,
Qt.ImageConversionFlags flags)
Constructs a pixmap from the file with the given fileName. |
Method Summary | |
---|---|
QPixmap |
alphaChannel()
Returns the alpha channel of the pixmap as a new grayscale QPixmap in which each pixel's red, green, and blue values are given the alpha value of the original pixmap. |
long |
cacheKey()
Returns a number that identifies this QPixmap . |
QPixmap |
clone()
This method is reimplemented for internal reasons |
QPixmap |
copy()
Returns a deep copy of the subset of the pixmap that is specified by the given rectangle. |
QPixmap |
copy(int x,
int y,
int width,
int height)
Returns a deep copy of the subset of the pixmap that is specified by the rectangle QRect ( x, y, width, height). |
QPixmap |
copy(QRect rect)
Returns a deep copy of the subset of the pixmap that is specified by the given rectangle. |
QBitmap |
createHeuristicMask()
Creates and returns a heuristic mask for this pixmap. |
QBitmap |
createHeuristicMask(boolean clipTight)
Creates and returns a heuristic mask for this pixmap. |
QBitmap |
createMaskFromColor(QColor maskColor)
Creates and returns a mask for this pixmap based on the given maskColor. |
QBitmap |
createMaskFromColor(QColor maskColor,
Qt.MaskMode mode)
Creates and returns a mask for this pixmap based on the given maskColor. |
static int |
defaultDepth()
Returns the default pixmap depth used by the application. |
int |
depth()
Returns the bit depth (number of bit planes) of the paint device. |
void |
fill()
Fills the pixmap with the given color. |
void |
fill(QColor fillColor)
Fills the pixmap with the given color. |
void |
fill(QWidget widget,
int xofs,
int yofs)
Fills the pixmap with the widget's background color or pixmap. |
void |
fill(QWidget widget,
QPoint ofs)
Fills the pixmap with the widget's background color or pixmap according to the given offset. |
static QPixmap |
fromImage(QImage image)
Converts the given image to a pixmap using the specified flags to control the conversion. |
static QPixmap |
fromImage(QImage image,
Qt.ImageConversionFlag[] flags)
Converts the given image to a pixmap using the specified flags to control the conversion. |
static QPixmap |
fromImage(QImage image,
Qt.ImageConversionFlags flags)
Converts the given image to a pixmap using the specified flags to control the conversion. |
static QPixmap |
fromNativePointer(QNativePointer nativePointer)
|
static QPixmap |
grabWidget(QWidget widget)
Creates a pixmap and paints the given widget, restricted by QRect (x, y, width, height), in it. |
static QPixmap |
grabWidget(QWidget widget,
int x)
Creates a pixmap and paints the given widget, restricted by QRect (x, y, width, height), in it. |
static QPixmap |
grabWidget(QWidget widget,
int x,
int y)
Creates a pixmap and paints the given widget, restricted by QRect (x, y, width, height), in it. |
static QPixmap |
grabWidget(QWidget widget,
int x,
int y,
int w)
Creates a pixmap and paints the given widget, restricted by QRect (x, y, width, height), in it. |
static QPixmap |
grabWidget(QWidget widget,
int x,
int y,
int w,
int h)
Creates a pixmap and paints the given widget, restricted by QRect (x, y, width, height), in it. |
static QPixmap |
grabWidget(QWidget widget,
QRect rect)
Creates a pixmap and paints the given widget, restricted by the given rectangle, in it. |
static QPixmap |
grabWindow(long arg__1)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect (x, y, width, height). |
static QPixmap |
grabWindow(long arg__1,
int x)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect (x, y, width, height). |
static QPixmap |
grabWindow(long arg__1,
int x,
int y)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect (x, y, width, height). |
static QPixmap |
grabWindow(long arg__1,
int x,
int y,
int w)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect (x, y, width, height). |
static QPixmap |
grabWindow(long arg__1,
int x,
int y,
int w,
int h)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by QRect (x, y, width, height). |
boolean |
hasAlpha()
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false. |
boolean |
hasAlphaChannel()
Returns true if the pixmap has a format that respects the alpha channel, otherwise returns false. |
int |
height()
Returns the height of the paint device in default coordinate system units (e.g. |
int |
heightMM()
Returns the height of the paint device in millimeters. |
boolean |
isNull()
Returns true if this is a null pixmap; otherwise returns false. |
boolean |
isQBitmap()
Returns true if this is a QBitmap ; otherwise returns false. |
boolean |
load(java.lang.String fileName)
This is an overloaded method provided for convenience. |
boolean |
load(java.lang.String fileName,
java.lang.String format)
This is an overloaded method provided for convenience. |
boolean |
load(java.lang.String fileName,
java.lang.String format,
Qt.ImageConversionFlag[] flags)
Constructs a pixmap from the file with the given fileName. |
boolean |
load(java.lang.String fileName,
java.lang.String format,
Qt.ImageConversionFlags flags)
Constructs a pixmap from the file with the given fileName. |
boolean |
loadFromData(byte[] data)
Loads a pixmap from the len first bytes of the given binary data. |
boolean |
loadFromData(byte[] data,
java.lang.String format)
Loads a pixmap from the len first bytes of the given binary data. |
boolean |
loadFromData(byte[] data,
java.lang.String format,
Qt.ImageConversionFlag[] flags)
Loads a pixmap from the len first bytes of the given binary data. |
boolean |
loadFromData(byte[] data,
java.lang.String format,
Qt.ImageConversionFlags flags)
Loads a pixmap from the len first bytes of the given binary data. |
boolean |
loadFromData(QByteArray data)
This is an overloaded method provided for convenience. |
boolean |
loadFromData(QByteArray data,
java.lang.String format)
This is an overloaded method provided for convenience. |
boolean |
loadFromData(QByteArray data,
java.lang.String format,
Qt.ImageConversionFlag[] flags)
Loads a pixmap from the binary data using the specified format and conversion flags. |
boolean |
loadFromData(QByteArray data,
java.lang.String format,
Qt.ImageConversionFlags flags)
Loads a pixmap from the binary data using the specified format and conversion flags. |
int |
logicalDpiX()
Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. |
int |
logicalDpiY()
Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. |
QBitmap |
mask()
Returns the mask, or a null bitmap if no mask has been set. |
int |
metric(QPaintDevice.PaintDeviceMetric arg__1)
Returns the metric information for the given paint device metric. |
static QNativePointer |
nativePointerArray(QPixmap[] array)
|
int |
numColors()
Returns the number of different colors available for the paint device. |
QPaintEngine |
paintEngine()
Returns a pointer to the paint engine used for drawing on the device. |
boolean |
paintingActive()
Returns true if the device is currently being painted on, i.e. |
int |
physicalDpiX()
Returns the horizontal resolution of the device in dots per inch. |
int |
physicalDpiY()
Returns the horizontal resolution of the device in dots per inch. |
void |
readFrom(QDataStream arg__1)
|
QRect |
rect()
Returns the pixmap's enclosing rectangle. |
boolean |
save(QIODevice dev)
This is an overloaded method provided for convenience. |
boolean |
save(QIODevice dev,
java.lang.String format)
This is an overloaded method provided for convenience. |
boolean |
save(QIODevice dev,
java.lang.String format,
int quality)
This function writes a QPixmap to the given dev using the specified image file format and quality factor. |
boolean |
save(java.lang.String fileName)
This is an overloaded method provided for convenience. |
boolean |
save(java.lang.String fileName,
java.lang.String format)
This is an overloaded method provided for convenience. |
boolean |
save(java.lang.String fileName,
java.lang.String format,
int quality)
Saves the pixmap to the file with the given fileName using the specified image file format and quality factor. |
QPixmap |
scaled(int w,
int h)
Returns a copy of the pixmap scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode. |
QPixmap |
scaled(int w,
int h,
Qt.AspectRatioMode aspectMode)
Returns a copy of the pixmap scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode. |
QPixmap |
scaled(int w,
int h,
Qt.AspectRatioMode aspectMode,
Qt.TransformationMode mode)
Returns a copy of the pixmap scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode. |
QPixmap |
scaled(QSize s)
Scales the pixmap to the given size, using the aspect ratio and transformation modes specified by aspectRatioMode and transformMode. |
QPixmap |
scaled(QSize s,
Qt.AspectRatioMode aspectMode)
Scales the pixmap to the given size, using the aspect ratio and transformation modes specified by aspectRatioMode and transformMode. |
QPixmap |
scaled(QSize s,
Qt.AspectRatioMode aspectMode,
Qt.TransformationMode mode)
Scales the pixmap to the given size, using the aspect ratio and transformation modes specified by aspectRatioMode and transformMode. |
QPixmap |
scaledToHeight(int h)
Returns a scaled copy of the image. |
QPixmap |
scaledToHeight(int h,
Qt.TransformationMode mode)
Returns a scaled copy of the image. |
QPixmap |
scaledToWidth(int w)
Returns a scaled copy of the image. |
QPixmap |
scaledToWidth(int w,
Qt.TransformationMode mode)
Returns a scaled copy of the image. |
void |
setAlphaChannel(QPixmap arg__1)
Sets the alpha channel of this pixmap to the given alphaChannel by converting the alphaChannel into 32 bit and using the intensity of the RGB pixel values. |
void |
setMask(QBitmap arg__1)
Sets a mask bitmap. |
QSize |
size()
Returns the size of the pixmap. |
QImage |
toImage()
Converts the pixmap to a QImage . |
QPixmap |
transformed(QMatrix arg__1,
Qt.TransformationMode mode)
This convenience function loads the matrix into a QTransform and calls the overloaded function. |
QPixmap |
transformed(QTransform arg__1,
Qt.TransformationMode mode)
Returns a copy of the pixmap that is transformed using the given transformation transform and transformation mode. |
static QMatrix |
trueMatrix(QMatrix m,
int w,
int h)
This convenience function loads the matrix m into a QTransform and calls the overloaded function with the QTransform and the width w and the height h. |
static QTransform |
trueMatrix(QTransform m,
int w,
int h)
Returns the actual matrix used for transforming a pixmap with the given width, height and matrix. |
int |
width()
Returns the width of the paint device in default coordinate system units (e.g. |
int |
widthMM()
Returns the width of the paint device in millimeters. |
void |
writeTo(QDataStream arg__1)
|
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QPixmap()
isNull()
.
public QPixmap(QPixmap arg__1)
copy()
.
public QPixmap(QSize arg__1)
public QPixmap(int w, int h)
The content of the pixmap is uninitialized. If either width or height is zero, a null pixmap is constructed.
isNull()
.
public QPixmap(java.lang.String[] xpm)
public QPixmap(java.lang.String fileName, java.lang.String format, Qt.ImageConversionFlags flags)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the Resource System overview for details on how to embed images and other resource files in the application's executable.
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 control the conversion.
The fileName, format and flags parameters are passed on to load()
. This means that the data in fileName is not compiled into the binary. If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
Reading and Writing Image Files
.
public QPixmap(java.lang.String fileName, java.lang.String format, Qt.ImageConversionFlag[] flags)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the Resource System overview for details on how to embed images and other resource files in the application's executable.
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 control the conversion.
The fileName, format and flags parameters are passed on to load()
. This means that the data in fileName is not compiled into the binary. If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
Reading and Writing Image Files
.
public QPixmap(java.lang.String fileName, java.lang.String format)
public QPixmap(java.lang.String fileName)
Errors are silently ignored.
Note that it's possible to squeeze the XPM variable a little bit by using an unusual declaration:
String start_xpm[] = { "16 15 8 1", "a c #cec6bd", // ... };The extra const 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.
Method Detail |
---|
public final QPixmap alphaChannel()
QPixmap
in which each pixel's red, green, and blue values are given the alpha value of the original pixmap. The color depth of the returned pixmap is the system depth on X11 and 8-bit on Windows and Mac OS X. You can use this function while debugging to get a visible image of the alpha channel. If the pixmap doesn't have an alpha channel, i.e., the alpha channel's value for all pixels equals 0xff), a null pixmap is returned. You can check this with the isNull() function.
We show an example:
pixmap = QPixmap(100, 100); pixmap.fill(Qt::transparent); QRadialGradient gradient(50, 50, 50, 50, 50); gradient.setColorAt(0, QColor::fromRgbF(1, 0, 0, 1)); gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0)); QPainter painter(&pixmap); painter.fillRect(0, 0, 100, 100, gradient); channelImage = pixmap.alphaChannel(); update();
setAlphaChannel()
, and Pixmap Information
.
public final long cacheKey()
QPixmap
. Distinct QPixmap
objects can only have the same cache key if they refer to the same contents. The cacheKey()
will change when the pixmap is altered.
public final QPixmap copy()
If the given rectangle is empty, the whole image is copied.
Pixmap Transformations
.
public final QPixmap copy(QRect rect)
If the given rectangle is empty, the whole image is copied.
Pixmap Transformations
.
public final QPixmap copy(int x, int y, int width, int height)
QRect
( x, y, width, height).
public final QBitmap createHeuristicMask()
The function works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges. If clipTight is true (the default) the mask is just large enough to cover the pixels; otherwise, the mask is larger than the data pixels.
The mask may not be perfect but it should be reasonable, so you can do things such as the following:
QPixmap myPixmap = new QPixmap(); myPixmap.setMask(myPixmap.createHeuristicMask());This function is slow because it involves converting to/from a
QImage
, and non-trivial computations. QImage::createHeuristicMask()
, and createMaskFromColor()
.
public final QBitmap createHeuristicMask(boolean clipTight)
The function works by selecting a color from one of the corners and then chipping away pixels of that color, starting at all the edges. If clipTight is true (the default) the mask is just large enough to cover the pixels; otherwise, the mask is larger than the data pixels.
The mask may not be perfect but it should be reasonable, so you can do things such as the following:
QPixmap myPixmap = new QPixmap(); myPixmap.setMask(myPixmap.createHeuristicMask());This function is slow because it involves converting to/from a
QImage
, and non-trivial computations. QImage::createHeuristicMask()
, and createMaskFromColor()
.
public final QBitmap createMaskFromColor(QColor maskColor)
Qt::MaskInColor
) createHeuristicMask()
, and QImage::createMaskFromColor()
.
public final QBitmap createMaskFromColor(QColor maskColor, Qt.MaskMode mode)
Qt::MaskInColor
, all pixels matching the maskColor
will be opaque. If mode is Qt::MaskOutColor
, all pixels matching the maskColor
will be transparent. This function is slow because it involves converting to/from a QImage
.
createHeuristicMask()
, and QImage::createMaskFromColor()
.
public final int depth()
depth
in interface QPaintDeviceInterface
public final void fill()
Pixmap Transformations
.
public final void fill(QColor fillColor)
Pixmap Transformations
.
public final void fill(QWidget widget, QPoint ofs)
The QPoint
offset defines a point in widget coordinates to which the pixmap's top-left pixel will be mapped to. This is only significant if the widget has a background pixmap; otherwise the pixmap will simply be filled with the background color of the widget.
public final void fill(QWidget widget, int xofs, int yofs)
public final boolean hasAlpha()
hasAlphaChannel()
, alphaChannel()
, and mask()
.
public final boolean hasAlphaChannel()
alphaChannel()
, and hasAlpha()
.
public final int height()
QPixmap
and QWidget
). heightMM()
.
height
in interface QPaintDeviceInterface
public final int heightMM()
height()
.
heightMM
in interface QPaintDeviceInterface
public final boolean isNull()
A null pixmap has zero width, zero height and no contents. You cannot draw in a null pixmap.
public final boolean isQBitmap()
QBitmap
; otherwise returns false.
public final int logicalDpiX()
widthMM()
. Note that if the logicalDpiX()
doesn't equal the physicalDpiX()
, the corresponding QPaintEngine
must handle the resolution mapping.
logicalDpiY()
, and physicalDpiX()
.
logicalDpiX
in interface QPaintDeviceInterface
public final int logicalDpiY()
heightMM()
. Note that if the logicalDpiY()
doesn't equal the physicalDpiY()
, the corresponding QPaintEngine
must handle the resolution mapping.
logicalDpiX()
, and physicalDpiY()
.
logicalDpiY
in interface QPaintDeviceInterface
public final QBitmap mask()
setMask()
, and Pixmap Information
.
public final int numColors()
INT_MAX
is returned instead.
numColors
in interface QPaintDeviceInterface
public final void writeTo(QDataStream arg__1)
public final void readFrom(QDataStream arg__1)
public final boolean paintingActive()
QPainter::begin()
but not yet called QPainter::end()
for this device; otherwise returns false. QPainter::isActive()
.
paintingActive
in interface QPaintDeviceInterface
public final int physicalDpiX()
Note that if the physicalDpiX()
doesn't equal the logicalDpiX()
, the corresponding QPaintEngine
must handle the resolution mapping.
physicalDpiY()
, and logicalDpiX()
.
physicalDpiX
in interface QPaintDeviceInterface
public final int physicalDpiY()
Note that if the physicalDpiY()
doesn't equal the logicalDpiY()
, the corresponding QPaintEngine
must handle the resolution mapping.
physicalDpiX()
, and logicalDpiY()
.
physicalDpiY
in interface QPaintDeviceInterface
public final QRect rect()
Pixmap Information
.
public final QPixmap scaled(QSize s, Qt.AspectRatioMode aspectMode)
Qt::IgnoreAspectRatio
, the pixmap is scaled to size.Qt::KeepAspectRatio
, the pixmap is scaled to a rectangle as large as possible inside size, preserving the aspect ratio.Qt::KeepAspectRatioByExpanding
, the pixmap is scaled to a rectangle as small as possible outside size, preserving the aspect ratio.isNull()
, and Pixmap Transformations
.
public final QPixmap scaled(QSize s)
Qt::IgnoreAspectRatio
, the pixmap is scaled to size.Qt::KeepAspectRatio
, the pixmap is scaled to a rectangle as large as possible inside size, preserving the aspect ratio.Qt::KeepAspectRatioByExpanding
, the pixmap is scaled to a rectangle as small as possible outside size, preserving the aspect ratio.isNull()
, and Pixmap Transformations
.
public final QPixmap scaled(QSize s, Qt.AspectRatioMode aspectMode, Qt.TransformationMode mode)
Qt::IgnoreAspectRatio
, the pixmap is scaled to size.Qt::KeepAspectRatio
, the pixmap is scaled to a rectangle as large as possible inside size, preserving the aspect ratio.Qt::KeepAspectRatioByExpanding
, the pixmap is scaled to a rectangle as small as possible outside size, preserving the aspect ratio.isNull()
, and Pixmap Transformations
.
public final QPixmap scaled(int w, int h, Qt.AspectRatioMode aspectMode)
If either the width or the height is zero or negative, this function returns a null pixmap.
public final QPixmap scaled(int w, int h)
If either the width or the height is zero or negative, this function returns a null pixmap.
public final QPixmap scaled(int w, int h, Qt.AspectRatioMode aspectMode, Qt.TransformationMode mode)
If either the width or the height is zero or negative, this function returns a null pixmap.
public final QPixmap scaledToHeight(int h)
If height is 0 or negative, a null pixmap is returned.
isNull()
, and Pixmap Transformations
.
public final QPixmap scaledToHeight(int h, Qt.TransformationMode mode)
If height is 0 or negative, a null pixmap is returned.
isNull()
, and Pixmap Transformations
.
public final QPixmap scaledToWidth(int w)
If width is 0 or negative, a null pixmap is returned.
isNull()
, and Pixmap Transformations
.
public final QPixmap scaledToWidth(int w, Qt.TransformationMode mode)
If width is 0 or negative, a null pixmap is returned.
isNull()
, and Pixmap Transformations
.
public final void setAlphaChannel(QPixmap arg__1)
The effect of this function is undefined when the pixmap is being painted on.
alphaChannel()
, and Pixmap Transformations
.
public final void setMask(QBitmap arg__1)
The mask bitmap defines the clip mask for this pixmap. Every pixel in mask 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.
Warning: Setting the mask on a pixmap will cause any alpha channel data to be cleared. For example:snippets/image/image.cppMASKQPixmapsetMask Now, alpha and alphacopy are visually different.
Setting a null mask resets the mask.
The effect of this function is undefined when the pixmap is being painted on.
mask()
, Pixmap Transformations
, and QBitmap
.
public final QSize size()
width()
, height()
, and Pixmap Information
.
public final QImage toImage()
QImage
. Returns a null image if the conversion fails. 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.
Note that for the moment, alpha masks on monochrome images are ignored.
fromImage()
, and Image Formats
.
public final QPixmap transformed(QMatrix arg__1, Qt.TransformationMode mode)
QTransform
and calls the overloaded function.
public final QPixmap transformed(QTransform arg__1, Qt.TransformationMode mode)
The transformation transform is internally adjusted to compensate for unwanted translation; i.e. the pixmap produced is the smallest pixmap that contains all the transformed points of the original pixmap. Use the trueMatrix()
function to retrieve the actual matrix used for transforming the pixmap.
This function is slow because it involves transformation to a QImage
, non-trivial computations and a transformation back to a QPixmap
.
trueMatrix()
, and Pixmap Transformations
.
public final int width()
QPixmap
and QWidget
). widthMM()
.
width
in interface QPaintDeviceInterface
public final int widthMM()
width()
.
widthMM
in interface QPaintDeviceInterface
public int metric(QPaintDevice.PaintDeviceMetric arg__1)
PaintDeviceMetric
.
metric
in interface QPaintDeviceInterface
public QPaintEngine paintEngine()
paintEngine
in interface QPaintDeviceInterface
public static int defaultDepth()
On Windows and Mac, the default depth is always 32. On X11 and embedded, the depth of the screen will be returned by this function.
depth()
, QColormap::depth()
, and Pixmap Information
.
public static QPixmap fromImage(QImage image, Qt.ImageConversionFlag[] flags)
In case of monochrome and 8-bit images, the image is first converted to a 32-bit pixmap and then filled with the colors in the color table. If this is too expensive an operation, you can use QBitmap::fromImage()
instead.
toImage()
, and Pixmap Conversion
.
public static QPixmap fromImage(QImage image)
In case of monochrome and 8-bit images, the image is first converted to a 32-bit pixmap and then filled with the colors in the color table. If this is too expensive an operation, you can use QBitmap::fromImage()
instead.
toImage()
, and Pixmap Conversion
.
public static QPixmap fromImage(QImage image, Qt.ImageConversionFlags flags)
In case of monochrome and 8-bit images, the image is first converted to a 32-bit pixmap and then filled with the colors in the color table. If this is too expensive an operation, you can use QBitmap::fromImage()
instead.
toImage()
, and Pixmap Conversion
.
public static QPixmap grabWidget(QWidget widget, QRect rect)
If no rectangle is specified (the default) the entire widget is painted.
If widget is 0, the specified rectangle doesn't overlap the widget's rectangle, or an error occurs, the function will return a null QPixmap
. If the rectangle is a superset of the given widget, the areas outside the widget are covered with the widget's background.
This function actually asks widget to paint itself (and its children to paint themselves) by calling paintEvent()
with painter redirection turned on. But QPixmap
also provides the grabWindow()
function which is a bit faster by grabbing pixels directly off the screen. In addition, if there are overlaying windows, grabWindow()
, unlike grabWidget()
, will see them.
Warning: Do not grab a widget from its QWidget::paintEvent()
. However, it is safe to grab a widget from another widget's paintEvent()
.
grabWindow()
.
public static QPixmap grabWidget(QWidget widget, int x, int y, int w)
QRect
(x, y, width, height), in it. Warning: Do not grab a widget from its QWidget::paintEvent()
. However, it is safe to grab a widget from another widget's paintEvent()
.
public static QPixmap grabWidget(QWidget widget, int x, int y)
QRect
(x, y, width, height), in it. Warning: Do not grab a widget from its QWidget::paintEvent()
. However, it is safe to grab a widget from another widget's paintEvent()
.
public static QPixmap grabWidget(QWidget widget, int x)
QRect
(x, y, width, height), in it. Warning: Do not grab a widget from its QWidget::paintEvent()
. However, it is safe to grab a widget from another widget's paintEvent()
.
public static QPixmap grabWidget(QWidget widget)
QRect
(x, y, width, height), in it. Warning: Do not grab a widget from its QWidget::paintEvent()
. However, it is safe to grab a widget from another widget's paintEvent()
.
public static QPixmap grabWidget(QWidget widget, int x, int y, int w, int h)
QRect
(x, y, width, height), in it. Warning: Do not grab a widget from its QWidget::paintEvent()
. However, it is safe to grab a widget from another widget's paintEvent()
.
public static QPixmap grabWindow(long arg__1, int x, int y, int w)
QRect
(x, y, width, height). The arguments (x, y) specify the offset in the window, whereas (width, height) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.
The window system identifier (WId) can be retrieved using the QWidget::winId()
function. The rationale for using a window identifier and not a QWidget
, is to enable grabbing of windows that are not part of the application, window system frames, and so on.
The grabWindow()
function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11that if the given window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.
Warning: In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.
grabWidget()
, and Screenshot Example.
public static QPixmap grabWindow(long arg__1, int x, int y)
QRect
(x, y, width, height). The arguments (x, y) specify the offset in the window, whereas (width, height) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.
The window system identifier (WId) can be retrieved using the QWidget::winId()
function. The rationale for using a window identifier and not a QWidget
, is to enable grabbing of windows that are not part of the application, window system frames, and so on.
The grabWindow()
function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11that if the given window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.
Warning: In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.
grabWidget()
, and Screenshot Example.
public static QPixmap grabWindow(long arg__1, int x)
QRect
(x, y, width, height). The arguments (x, y) specify the offset in the window, whereas (width, height) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.
The window system identifier (WId) can be retrieved using the QWidget::winId()
function. The rationale for using a window identifier and not a QWidget
, is to enable grabbing of windows that are not part of the application, window system frames, and so on.
The grabWindow()
function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11that if the given window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.
Warning: In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.
grabWidget()
, and Screenshot Example.
public static QPixmap grabWindow(long arg__1)
QRect
(x, y, width, height). The arguments (x, y) specify the offset in the window, whereas (width, height) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.
The window system identifier (WId) can be retrieved using the QWidget::winId()
function. The rationale for using a window identifier and not a QWidget
, is to enable grabbing of windows that are not part of the application, window system frames, and so on.
The grabWindow()
function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11that if the given window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.
Warning: In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.
grabWidget()
, and Screenshot Example.
public static QPixmap grabWindow(long arg__1, int x, int y, int w, int h)
QRect
(x, y, width, height). The arguments (x, y) specify the offset in the window, whereas (width, height) specify the area to be copied. If width is negative, the function copies everything to the right border of the window. If height is negative, the function copies everything to the bottom of the window.
The window system identifier (WId) can be retrieved using the QWidget::winId()
function. The rationale for using a window identifier and not a QWidget
, is to enable grabbing of windows that are not part of the application, window system frames, and so on.
The grabWindow()
function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
Note on X11that if the given window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized.
Warning: In general, grabbing an area outside the screen is not safe. This depends on the underlying window system.
grabWidget()
, and Screenshot Example.
public static QMatrix trueMatrix(QMatrix m, int w, int h)
QTransform
and calls the overloaded function with the QTransform
and the width w and the height h.
public static QTransform trueMatrix(QTransform m, int w, int h)
When transforming a pixmap using the transformed()
function, the transformation matrix is internally adjusted to compensate for unwanted translation, i.e. transformed()
returns the smallest pixmap containing all transformed points of the original pixmap. This function returns the modified matrix, which maps points correctly from the original pixmap into the new pixmap.
transformed()
, and Pixmap Transformations
.
public static QPixmap fromNativePointer(QNativePointer nativePointer)
public static QNativePointer nativePointerArray(QPixmap[] array)
public final boolean save(QIODevice dev, java.lang.String format, int quality)
public final boolean save(QIODevice dev, java.lang.String format)
public final boolean save(QIODevice dev)
public final boolean save(java.lang.String fileName, java.lang.String format, int quality)
The quality factor 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.
If format is 0, an image format will be chosen from fileName's suffix.
public final boolean save(java.lang.String fileName, java.lang.String format)
public final boolean save(java.lang.String fileName)
public final boolean load(java.lang.String fileName, java.lang.String format, Qt.ImageConversionFlags flags)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the Resource System overview for details on how to embed images and other resource files in the application's executable.
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 control the conversion.
The fileName, format and flags parameters are passed on to load()
. This means that the data in fileName is not compiled into the binary. If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
Reading and Writing Image Files
.
public final boolean load(java.lang.String fileName, java.lang.String format, Qt.ImageConversionFlag[] flags)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
The file name can either refer to an actual file on disk or to one of the application's embedded resources. See the Resource System overview for details on how to embed images and other resource files in the application's executable.
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 control the conversion.
The fileName, format and flags parameters are passed on to load()
. This means that the data in fileName is not compiled into the binary. If fileName contains a relative path (e.g. the filename only) the relevant file must be found relative to the runtime working directory.
Reading and Writing Image Files
.
public final boolean load(java.lang.String fileName, java.lang.String format)
public final boolean load(java.lang.String fileName)
public final boolean loadFromData(byte[] data, java.lang.String format, Qt.ImageConversionFlags flags)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
load()
, and Reading and Writing Image Files
.
public final boolean loadFromData(byte[] data, java.lang.String format, Qt.ImageConversionFlag[] flags)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
load()
, and Reading and Writing Image Files
.
public final boolean loadFromData(byte[] data, java.lang.String format)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
load()
, and Reading and Writing Image Files
.
public final boolean loadFromData(byte[] data)
The loader attempts to read the pixmap using the specified format. If the format is not specified (which is the default), the loader probes the file for a header to guess the file format.
If the data needs to be modified to fit in a lower-resolution result (e.g. converting from 32-bit to 8-bit), use the flags to control the conversion.
load()
, and Reading and Writing Image Files
.
public final boolean loadFromData(QByteArray data, java.lang.String format, Qt.ImageConversionFlags flags)
public final boolean loadFromData(QByteArray data, java.lang.String format, Qt.ImageConversionFlag[] flags)
public final boolean loadFromData(QByteArray data, java.lang.String format)
public final boolean loadFromData(QByteArray data)
public QPixmap clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |