5#include <private/qpicture_p.h>
9#include <private/qfactoryloader_p.h>
10#include <private/qpaintengine_pic_p.h>
11#include <private/qfont_p.h>
23#include <QtCore/private/qlocking_p.h>
31 int tabstops,
int *,
int tabarraylen,
108 if (formatVersion == 0)
109 qWarning(
"QPicture: invalid format version 0");
112 if (formatVersion > 0 && formatVersion != (
int)
mfhdr_maj) {
113 d->formatMajor = formatVersion;
182 return d_func()->pictb.buffer().isNull();
187 return d_func()->pictb.buffer().size();
192 return d_func()->pictb.buffer();
202 return d_func()->ref.loadRelaxed() == 1;
215 d_func()->pictb.setData(
data,
size);
216 d_func()->resetFormat();
248 d_func()->pictb.setData(
a);
249 return d_func()->checkFormat();
262 qWarning(
"QPicture::save: still being painted on. "
263 "Call QPainter::end() first");
282 qWarning(
"QPicture::save: still being painted on. "
283 "Call QPainter::end() first");
287 dev->
write(d_func()->pictb.buffer(), d_func()->pictb.buffer().size());
300 if (!
d->override_rect.isEmpty())
301 return d->override_rect;
316 d_func()->override_rect =
r;
333 if (
d->pictb.size() == 0)
336 if (!
d->formatOk && !
d->checkFormat())
341 s.setDevice(&
d->pictb);
342 s.device()->seek(10);
343 s.setVersion(
d->formatMajor == 4 ? 3 :
d->formatMajor);
350 if (
d->formatMajor >= 4) {
352 s >> dummy >> dummy >> dummy >> dummy;
356 qWarning(
"QPicture::play: Format error");
409 qint16 i_16, i1_16, i2_16;
435 while (nrecords-- && !
s.atEnd()) {
443 strm_pos =
s.device()->pos();
449 if (
d->formatMajor <= 5) {
469 if (
d->formatMajor <= 5) {
478 if (
d->formatMajor <= 5) {
487 if (
d->formatMajor <= 5) {
488 s >> ir >> i1_16 >> i2_16;
491 s >>
r >> i1_16 >> i2_16;
496 if (
d->formatMajor <= 5) {
505 if (
d->formatMajor <= 5) {
515 if (
d->formatMajor <= 5) {
525 if (
d->formatMajor <= 5) {
540 if (
d->formatMajor <= 5) {
551 if (
d->formatMajor <= 5) {
565 path.moveTo(ia.value(0));
566 path.cubicTo(ia.value(1), ia.value(2), ia.value(3));
576 s >> ir >> i_16 >> str1;
580 if (
d->formatMajor <= 5) {
601 if (
d->formatMajor >= 9) {
611 qreal justificationWidth;
612 s >> justificationWidth;
617 if (justificationWidth > 0) {
618 size.setWidth(justificationWidth);
636 if (
d->formatMajor < 4) {
639 }
else if (
d->formatMajor <= 5) {
644 if (
d->in_memory_only) {
647 Q_ASSERT(index < d->pixmap_list.size());
658 if (
d->in_memory_only) {
661 Q_ASSERT(index < d->pixmap_list.size());
671 if (
d->formatMajor < 4) {
674 }
else if (
d->formatMajor <= 5){
679 if (
d->in_memory_only) {
682 Q_ASSERT(index < d->image_list.size());
718 if (
d->formatMajor <= 5) {
731 if (
d->in_memory_only) {
734 Q_ASSERT(index < d->pen_list.size());
735 pen =
d->pen_list.value(
index);
742 if (
d->in_memory_only) {
745 Q_ASSERT(index < d->brush_list.size());
757 if (
d->formatMajor <= 5) {
766 if (
d->formatMajor <= 5) {
779 if (
d->formatMajor >= 8) {
782 s >> wmatrix[0] >> wmatrix[1]
783 >> wmatrix[2] >> wmatrix[3]
784 >> wmatrix[4] >> wmatrix[5] >> i_8;
786 wmatrix[2], wmatrix[3],
787 wmatrix[4], wmatrix[5]);
798 if (
d->formatMajor >= 9) {
833 qWarning(
"QPicture::play: Invalid command %d",
c);
835 s.device()->seek(
s.device()->pos()+
len);
896 qWarning(
"QPicture::metric: Invalid metric command");
940 : in_memory_only(
false)
950 : trecs(
other.trecs),
951 formatOk(
other.formatOk),
952 formatMinor(
other.formatMinor),
954 override_rect(
other.override_rect),
955 in_memory_only(
false)
958 if (
other.pictb.isOpen()) {
998 s.readRawData(mf_id, 4);
1001 qWarning(
"QPicturePaintEngine::checkFormat: Incorrect header");
1006 int cs_start =
sizeof(
quint32);
1007 int data_start = cs_start +
sizeof(
quint16);
1014 qWarning(
"QPicturePaintEngine::checkFormat: Invalid checksum %x, %x expected",
1021 s >> major >> minor;
1023 qWarning(
"QPicturePaintEngine::checkFormat: Incompatible version %d.%d",
1028 s.setVersion(major != 4 ? major : 3);
1033 if (!(major >= 1 && major <= 3)) {
1035 s >> l >>
t >>
w >>
h;
1039 qWarning(
"QPicturePaintEngine::checkFormat: Format error");
1056 return d_func()->paintEngine.data();
1063#ifndef QT_NO_DATASTREAM
1079 s.writeRawData (
r.d_func()->pictb.buffer(),
r.d_func()->pictb.buffer().size());
1105 r.d_func()->pictb.setData(
data);
1106 r.d_func()->resetFormat();
bool open(OpenMode openMode) override
\reimp
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
void close() override
\reimp
qint64 size() const override
\reimp
bool seek(qint64 off) override
\reimp
QByteArray & buffer()
Returns a reference to the QBuffer's internal buffer.
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
The QColor class provides colors based on RGB, HSV or CMYK values.
\inmodule QtCore\reentrant
@ Qt_DefaultCompiledVersion
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
void setVersion(int)
Sets the version number of the data serialization format to v, a value of the \l Version enum.
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
QPaintEngine * paintEngine() const override
int metric(PaintDeviceMetric m) const override
\reentrant \inmodule QtGui
\inmodule QtCore \reentrant
bool isOpen() const
Returns true if the device is open; otherwise returns false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
bool paintingActive() const
@ PdmDevicePixelRatioScaled
virtual int metric(PaintDeviceMetric metric) const
static qreal devicePixelRatioFScale()
The QPainter class performs low-level painting on widgets and other paint devices.
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen's color.
const QPen & pen() const
Returns the painter's current pen.
void setBackground(const QBrush &bg)
Sets the background brush of the painter to the given brush.
void setClipping(bool enable)
Enables clipping if enable is true, or disables clipping if enable is false.
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
QPaintDevice * device() const
Returns the paint device on which this painter is currently painting, or \nullptr if the painter is n...
void setWorldMatrixEnabled(bool enabled)
void drawPie(const QRectF &rect, int a, int alen)
Draws a pie defined by the given rectangle, startAngle and spanAngle.
void strokePath(const QPainterPath &path, const QPen &pen)
Draws the outline (strokes) the path path with the pen specified by pen.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
void setViewport(const QRect &viewport)
Sets the painter's viewport rectangle to the given rectangle, and enables view transformations.
void drawChord(const QRectF &rect, int a, int alen)
Draws the chord defined by the given rectangle, startAngle and spanAngle.
void setBrushOrigin(int x, int y)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setClipPath(const QPainterPath &path, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip path for the painter to the given path, with the clip operation.
void setBackgroundMode(Qt::BGMode mode)
Sets the background mode of the painter to the given mode.
void drawTiledPixmap(const QRectF &rect, const QPixmap &pm, const QPointF &offset=QPointF())
Draws a tiled pixmap, inside the given rectangle with its origin at the given position.
void restore()
Restores the current painter state (pops a saved state off the stack).
void setOpacity(qreal opacity)
void drawLines(const QLineF *lines, int lineCount)
Draws the first lineCount lines in the array lines using the current pen.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
void save()
Saves the current painter state (pushes the state onto a stack).
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
@ NonCosmeticBrushPatterns
const QTransform & transform() const
Alias for worldTransform().
CompositionMode
Defines the modes supported for digital image compositing.
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
void setViewTransformEnabled(bool enable)
Enables view transformations if enable is true, or disables view transformations if enable is false.
void setWindow(const QRect &window)
Sets the painter's window to the given rectangle, and enables view transformations.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
void setClipRegion(const QRegion &, Qt::ClipOperation op=Qt::ReplaceClip)
Sets the clip region to the given region using the specified clip operation.
void setTransform(const QTransform &transform, bool combine=false)
The QPicture class is a paint device that records and replays QPainter commands.
virtual void setData(const char *data, uint size)
Sets the picture data directly from data and size.
bool load(QIODevice *dev)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const char * data() const
Returns a pointer to the picture data.
void setBoundingRect(const QRect &r)
Sets the picture's bounding rectangle to r.
QRect boundingRect() const
Returns the picture's bounding rectangle or an invalid rectangle if the picture contains no data.
QPicture(int formatVersion=-1)
Constructs an empty picture.
uint size() const
Returns the size of the picture data.
QPaintEngine * paintEngine() const override
QPicture & operator=(const QPicture &p)
Move-assigns other to this QPicture instance.
int metric(PaintDeviceMetric m) const override
int devType() const override
bool save(QIODevice *dev)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isNull() const
Returns true if the picture contains no data; otherwise returns false.
bool play(QPainter *p)
Replays the picture using painter, and returns true if successful; otherwise returns false.
~QPicture()
Destroys the picture.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QPolygonF class provides a list of points using floating point precision.
The QPolygon class provides a list of points using integer precision.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int width() const noexcept
Returns the width of the rectangle.
The QRegion class specifies a clip region for a painter.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Combined button and popup list for selecting options.
@ TextJustificationForced
Q_CORE_EXPORT quint16 qChecksum(QByteArrayView data, Qt::ChecksumType standard=Qt::ChecksumIso3309)
int qRound(qfloat16 d) noexcept
Q_GUI_EXPORT int qt_defaultDpiX()
Q_GUI_EXPORT int qt_defaultDpiY()
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat GLfloat GLfloat h
GLsizei const GLchar *const * path
const char * qt_mfhdr_tag
static const quint16 mfhdr_maj
static const quint16 mfhdr_min
QT_BEGIN_NAMESPACE void qt_format_text(const QFont &fnt, const QRectF &_r, int tf, const QTextOption *opt, const QString &str, QRectF *brect, int tabstops, int *, int tabarraylen, QPainter *painter)
const char * qt_mfhdr_tag
QT_BEGIN_NAMESPACE typedef signed char qint8