Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QPicture

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.gui.QPicture

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface, java.lang.Cloneable

    public class QPicture

extends QtJambiObject
implements QPaintDeviceInterface, java.lang.Cloneable

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 = new QPicture();
                QPainter painter = new QPainter();
                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 = new QPicture();
                picture.load("drawing.pic");           // load picture
                QPainter painter = new QPainter();
                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()`.

See also:
  `QMovie`.

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
`QPicture()` Constructs an empty picture.
`QPicture(int formatVersion)` Constructs an empty picture.
`QPicture(QPicture arg__1)` Constructs a copy of `pic`.

Method Summary
`QRect` | `boundingRect()` Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
`QPicture` | `clone()` This method is reimplemented for internal reasons
`byte[]` | `data()` Returns the picture data.
`int` | `depth()` Returns the bit depth (number of bit planes) of the paint device.
`static QPicture` | `fromNativePointer(QNativePointer nativePointer)` This method returns the QPicture instance pointed to by `nativePointer`.
`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 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)` Returns the metric information for the given paint device `metric`.
`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.
`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 `painter`, and returns true if successful; otherwise returns false.
`void` | `readFrom(QDataStream arg__1)` Reads a QPicture
`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)` Sets the picture data directly from `data` and `size`.
`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.
`int` | `widthMM()` Returns the width of the paint device in millimeters.
`void` | `writeTo(QDataStream arg__1)` Writes thisQPicture

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

### QPicture

    public QPicture(QPicture arg__1)

  Constructs a copy of `pic`.

  This constructor is fast thanks to implicit sharing.

### QPicture

    public QPicture()

  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.

### QPicture

    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.

Method Detail

### boundingRect

    public final QRect boundingRect()

  Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.

See also:
  `setBoundingRect()`.

### depth

    public final int depth()

  Returns the bit depth (number of bit planes) of the paint device.

  Specified by:
    `depth` in interface `QPaintDeviceInterface`

### height

    public final int height()

  Returns the height of the paint device in default coordinate system units (e.g. pixels for `QPixmap` and `QWidget`).

See also:
  `heightMM()`.

  Specified by:
    `height` in interface `QPaintDeviceInterface`

### heightMM

    public final int heightMM()

  Returns the height of the paint device in millimeters.

See also:
  `height()`.

  Specified by:
    `heightMM` in interface `QPaintDeviceInterface`

### isNull

    public final boolean isNull()

  Returns true if the picture contains no data; otherwise returns false.

### logicalDpiX

    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()`.

  Note that if the `logicalDpiX()` doesn't equal the `physicalDpiX()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `logicalDpiY()`, and `physicalDpiX()`.

  Specified by:
    `logicalDpiX` in interface `QPaintDeviceInterface`

### logicalDpiY

    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()`.

  Note that if the `logicalDpiY()` doesn't equal the `physicalDpiY()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `logicalDpiX()`, and `physicalDpiY()`.

  Specified by:
    `logicalDpiY` in interface `QPaintDeviceInterface`

### numColors

    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.

  Specified by:
    `numColors` in interface `QPaintDeviceInterface`

### writeTo

    public final void writeTo(QDataStream arg__1)

  Writes thisQPicture

### readFrom

    public final void readFrom(QDataStream arg__1)

  Reads a QPicture

### paintingActive

    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.

See also:
  `QPainter::isActive()`.

  Specified by:
    `paintingActive` in interface `QPaintDeviceInterface`

### physicalDpiX

    public final int physicalDpiX()

  Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

  Note that if the `physicalDpiX()` doesn't equal the `logicalDpiX()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `physicalDpiY()`, and `logicalDpiX()`.

  Specified by:
    `physicalDpiX` in interface `QPaintDeviceInterface`

### physicalDpiY

    public final int physicalDpiY()

  Returns the horizontal resolution of the device in dots per inch. For example, when printing, this resolution refers to the physical printer's resolution. The logical DPI on the other hand, refers to the resolution used by the actual paint engine.

  Note that if the `physicalDpiY()` doesn't equal the `logicalDpiY()`, the corresponding `QPaintEngine` must handle the resolution mapping.

See also:
  `physicalDpiX()`, and `logicalDpiY()`.

  Specified by:
    `physicalDpiY` in interface `QPaintDeviceInterface`

### play

    public final boolean play(QPainter p)

  Replays the picture using `painter`, and returns true if successful; otherwise returns false.

  This function does exactly the same as `QPainter::drawPicture()` with (x, y) = (0, 0).

### setBoundingRect

    public final void setBoundingRect(QRect r)

  Sets the picture's bounding rectangle to `r`. The automatically calculated value is overridden.

See also:
  `boundingRect()`.

### size

    public final int size()

  Returns the size of the picture data.

See also:
  `data()`.

### width

    public final int width()

  Returns the width of the paint device in default coordinate system units (e.g. pixels for `QPixmap` and `QWidget`).

See also:
  `widthMM()`.

  Specified by:
    `width` in interface `QPaintDeviceInterface`

### widthMM

    public final int widthMM()

  Returns the width of the paint device in millimeters.

See also:
  `width()`.

  Specified by:
    `widthMM` in interface `QPaintDeviceInterface`

### metric

    public int metric(QPaintDevice.PaintDeviceMetric m)

  Returns the metric information for the given paint device `metric`.

See also:
  `PaintDeviceMetric` .

  Specified by:
    `metric` in interface `QPaintDeviceInterface`

### paintEngine

    public QPaintEngine paintEngine()

  Returns a pointer to the paint engine used for drawing on the device.

  Specified by:
    `paintEngine` in interface `QPaintDeviceInterface`

### setData

    public void setData(byte[] data)

  Sets the picture data directly from `data` and `size`. This function copies the input data.

See also:
  `data()`, and `size()`.

### fromNativePointer

    public static QPicture fromNativePointer(QNativePointer nativePointer)

  This method returns the QPicture instance pointed to by `nativePointer`.

### nativePointerArray

    public static QNativePointer nativePointerArray(QPicture[] array)

  This function returns a QNativePointer that is pointing to the specified QPicture array.

### load

    public final boolean load(QIODevice dev)

  This is an overloaded member function, provided for convenience. `dev` is the device used for loading.

### load

    public final boolean load(java.lang.String fileName)

  Loads a picture from the file specified by fileName and returns true if successful; otherwise returns false.

### save

    public final boolean save(QIODevice dev)

  This is an overloaded member function, provided for convenience.

  `dev` is the device to use for saving.

### save

    public final boolean save(java.lang.String fileName)

  Saves a picture to the file specified by `fileName` and returns true if successful; otherwise returns false.

### data

    public final byte[] data()

  Returns the picture data.

### clone

    public QPicture clone()

  This method is reimplemented for internal reasons

  Overrides:
    `clone` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD