|
|
||||||||||
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.QPicture
public class QPicture
The QPicture class is a paint device that records and replays QPainter commands.
A picture serializes painter commands to an IO device in a platform-independent format. They are sometimes referred to as meta-files.
Qt pictures use a proprietary binary format. Unlike native picture (meta-file) formats on many window systems, Qt pictures have no limitations regarding their contents. Everything that can be painted on a widget or pixmap (e.g., fonts, pixmaps, regions, transformed graphics, etc.) can also be stored in a picture.
QPicture is resolution independent, i.e. a QPicture can be displayed on different devices (for example svg, pdf, ps, printer and screen) looking the same. This is, for instance, needed for WYSIWYG print preview. QPicture runs in the default system dpi, and scales the painter to match differences in resolution depending on the window system.
Example of how to record a picture:
QPicture picture; QPainter painter; painter.begin(&picture); // paint in picture painter.drawEllipse(10,20, 80,70); // draw an ellipse painter.end(); // painting done picture.save("drawing.pic"); // save picture
Note that the list of painter commands is reset on each call to the QPainter::begin() function.
Example of how to replay a picture:
QPicture picture; picture.load("drawing.pic"); // load picture QPainter painter; painter.begin(&myWidget); // paint in myWidget painter.drawPicture(0, 0, picture); // draw the picture at (0,0) painter.end(); // painting done
Pictures can also be drawn using play. Some basic data about a picture is available, for example, size, isNull and boundingRect.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QPicture()
Equivalent to QPicture(-1). |
|
QPicture(int formatVersion)
Constructs an empty picture. |
|
QPicture(QPicture arg__1)
Constructs a copy of arg__1. |
Method Summary | |
---|---|
QRect |
boundingRect()
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data. |
byte[] |
data()
Returns the picture data. |
int |
depth()
Returns the bit depth (number of bit planes) of the paint device. |
int |
devType()
|
static QPicture |
fromNativePointer(QNativePointer nativePointer)
This function returns the QPicture instance pointed to by nativePointer |
int |
height()
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). |
int |
heightMM()
Returns the height of the paint device in millimeters. |
boolean |
isNull()
Returns true if the picture contains no data; otherwise returns false. |
boolean |
load(QIODevice dev)
This is an overloaded member function, provided for convenience. |
boolean |
load(java.lang.String fileName)
Loads a picture from the file specified by fileName and returns true if successful; otherwise returns false. |
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. |
int |
metric(QPaintDevice.PaintDeviceMetric m)
Internal implementation of the virtual QPaintDevice::metric() function. |
static QNativePointer |
nativePointerArray(QPicture[] array)
This function returns a QNativePointer that is pointing to the specified QPicture 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. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false. |
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. |
boolean |
play(QPainter p)
Replays the picture using p, and returns true if successful; otherwise returns false. |
void |
readFrom(QDataStream arg__1)
Reads a QPicture from arg__1. |
boolean |
save(QIODevice dev)
This is an overloaded member function, provided for convenience. |
boolean |
save(java.lang.String fileName)
Saves a picture to the file specified by fileName and returns true if successful; otherwise returns false. |
void |
setBoundingRect(QRect r)
Sets the picture's bounding rectangle to r. |
void |
setData(byte[] data)
Equivalent to setData(data, ). |
int |
size()
Returns the size of the picture data. |
int |
width()
Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). |
int |
widthMM()
Returns the width of the paint device in millimeters. |
void |
writeTo(QDataStream arg__1)
Writes thisQPicture to arg__1. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, 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 |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QPicture()
Equivalent to QPicture(-1).
public QPicture(int formatVersion)
Constructs an empty picture.
The formatVersion parameter may be used to create a QPicture that can be read by applications that are compiled with earlier versions of Qt.
Note that the default formatVersion is -1 which signifies the current release, i.e. for Qt 4.0 a formatVersion of 7 is the same as the default formatVersion of -1.
Reading pictures generated by earlier versions of Qt is not supported in Qt 4.0.
public QPicture(QPicture arg__1)
Constructs a copy of arg__1.
This constructor is fast thanks to implicit sharing.
Method Detail |
---|
public final QRect boundingRect()
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
public final int depth()
Returns the bit depth (number of bit planes) of the paint device.
depth
in interface QPaintDeviceInterface
public final int height()
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
height
in interface QPaintDeviceInterface
public final int heightMM()
Returns the height of the paint device in millimeters.
heightMM
in interface QPaintDeviceInterface
public final boolean isNull()
Returns true if the picture contains no data; otherwise returns false.
public final int logicalDpiX()
Returns the horizontal resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from widthMM, but it varies on Windows.
Note that if the logicalDpiX doesn't equal the physicalDpiX, the corresponding QPaintEngine must handle the resolution mapping.
logicalDpiX
in interface QPaintDeviceInterface
public final int logicalDpiY()
Returns the vertical resolution of the device in dots per inch, which is used when computing font sizes. For X11, this is usually the same as could be computed from heightMM, but it varies on Windows.
Note that if the logicalDpiY doesn't equal the physicalDpiY, the corresponding QPaintEngine must handle the resolution mapping.
logicalDpiY
in interface QPaintDeviceInterface
public final int numColors()
Returns the number of different colors available for the paint device. Since this value is an int, it will not be sufficient to represent the number of colors on 32 bit displays, in this case 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()
Returns true if the device is currently being painted on, i.e. someone has called QPainter::begin() but not yet called QPainter::end() for this device; otherwise returns false.
paintingActive
in interface QPaintDeviceInterface
public final int physicalDpiX()
Returns the horizontal resolution of the device in dots per inch.
Note that if the physicalDpiX doesn't equal the logicalDpiX, the corresponding QPaintEngine must handle the resolution mapping.
physicalDpiX
in interface QPaintDeviceInterface
public final int physicalDpiY()
Returns the horizontal resolution of the device in dots per inch.
Note that if the physicalDpiY doesn't equal the logicalDpiY, the corresponding QPaintEngine must handle the resolution mapping.
physicalDpiY
in interface QPaintDeviceInterface
public final boolean play(QPainter p)
Replays the picture using p, and returns true if successful; otherwise returns false.
This function does exactly the same as QPainter::drawPicture() with (x, y) = (0, 0).
public final void setBoundingRect(QRect r)
Sets the picture's bounding rectangle to r. The automatically calculated value is overridden.
public final int size()
Returns the size of the picture data.
public final int width()
Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
width
in interface QPaintDeviceInterface
public final int widthMM()
Returns the width of the paint device in millimeters.
widthMM
in interface QPaintDeviceInterface
public int devType()
devType
in interface QPaintDeviceInterface
public int metric(QPaintDevice.PaintDeviceMetric m)
Internal implementation of the virtual QPaintDevice::metric() function.
A picture has the following hard-coded values: numcolors=16777216 and depth=24.
m is the metric to get.
metric
in interface QPaintDeviceInterface
public QPaintEngine paintEngine()
Returns a pointer to the paint engine used for drawing on the device.
paintEngine
in interface QPaintDeviceInterface
public void setData(byte[] data)
Equivalent to setData(data, ).
public static QPicture fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.public static QNativePointer nativePointerArray(QPicture[] array)
array
- the array that the returned pointer will point to.
public final boolean load(QIODevice dev)
public final boolean load(java.lang.String fileName)
public final boolean save(QIODevice dev)
dev is the device to use for saving.
public final boolean save(java.lang.String fileName)
public final byte[] data()
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |