Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickpixmap_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKPIXMAP_H
5#define QQUICKPIXMAP_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qcoreapplication.h>
19#include <QtCore/qstring.h>
20#include <QtGui/qpixmap.h>
21#include <QtCore/qmutex.h>
22#include <QtCore/qurl.h>
23#include <private/qtquickglobal_p.h>
24#include <QtQuick/qquickimageprovider.h>
25
27
28class QQmlEngine;
32
34{
36public:
39 QSize textureSize() const override { return size; }
40 int textureByteCount() const override { return size.width() * size.height() * 4; }
41 QImage image() const override { return im; }
42
43private:
44 QImage im;
45 QSize size;
46};
47
55
56// ### Qt 6: Make public moving to qquickimageprovider.h
57class Q_QUICK_EXPORT QQuickImageProviderOptions
58{
59public:
61 UsePluginDefaultTransform = -1,
62 ApplyTransform = 0,
63 DoNotApplyTransform = 1
64 };
65
68
71
72 bool operator==(const QQuickImageProviderOptions&) const;
73
74 AutoTransform autoTransform() const;
75 void setAutoTransform(AutoTransform autoTransform);
76
77 bool preserveAspectRatioCrop() const;
78 void setPreserveAspectRatioCrop(bool preserveAspectRatioCrop);
79
80 bool preserveAspectRatioFit() const;
81 void setPreserveAspectRatioFit(bool preserveAspectRatioFit);
82
83 QColorSpace targetColorSpace() const;
84 void setTargetColorSpace(const QColorSpace &colorSpace);
85
86 QRectF sourceClipRect() const;
87 void setSourceClipRect(const QRectF &rect);
88
89private:
90 QSharedDataPointer<QQuickImageProviderOptionsPrivate> d;
91};
92
103class Q_QUICK_EXPORT QQuickPixmap
104{
106public:
107 enum Status { Null, Ready, Error, Loading };
108
109 enum Option {
110 Asynchronous = 0x00000001,
111 Cache = 0x00000002
112 };
114
115 QQuickPixmap();
116 QQuickPixmap(QQmlEngine *, const QUrl &);
117 QQuickPixmap(QQmlEngine *, const QUrl &, Options options);
118 QQuickPixmap(QQmlEngine *, const QUrl &, const QRect &region, const QSize &);
119 QQuickPixmap(const QUrl &, const QImage &image);
121
122 bool isNull() const;
123 bool isReady() const;
124 bool isError() const;
125 bool isLoading() const;
126
127 Status status() const;
128 QString error() const;
129 const QUrl &url() const;
130 const QSize &implicitSize() const;
131 const QRect &requestRegion() const;
132 const QSize &requestSize() const;
133 QQuickImageProviderOptions::AutoTransform autoTransform() const;
134 int frameCount() const;
135 QImage image() const;
136 void setImage(const QImage &);
137 void setPixmap(const QQuickPixmap &other);
138
139 QColorSpace colorSpace() const;
140
141 QQuickTextureFactory *textureFactory() const;
142
143 QRect rect() const;
144 int width() const;
145 int height() const;
146
147 void load(QQmlEngine *, const QUrl &);
148 void load(QQmlEngine *, const QUrl &, QQuickPixmap::Options options);
149 void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize);
150 void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize, QQuickPixmap::Options options);
151 void load(QQmlEngine *, const QUrl &, const QRect &requestRegion, const QSize &requestSize,
152 QQuickPixmap::Options options, const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1,
153 qreal devicePixelRatio = 1.0);
154 void loadImageFromDevice(QQmlEngine *engine, QIODevice *device, const QUrl &url,
155 const QRect &requestRegion, const QSize &requestSize,
156 const QQuickImageProviderOptions &providerOptions, int frame = 0, int frameCount = 1);
157
158 void clear();
159 void clear(QObject *);
160
161 bool connectFinished(QObject *, const char *);
162 bool connectFinished(QObject *, int);
163 bool connectDownloadProgress(QObject *, const char *);
164 bool connectDownloadProgress(QObject *, int);
165
166 static void purgeCache();
167 static bool isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize,
168 const int frame, const QQuickImageProviderOptions &options);
169 static bool isScalableImageFormat(const QUrl &url);
170
172
173private:
174 Q_DISABLE_COPY(QQuickPixmap)
176 friend class QQuickPixmapData;
177};
178
179Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPixmap::Options)
180
181// ### Qt 6: This should be made public in Qt 6. It's functionality can't be merged into
182// QQuickImageProvider without breaking source compatibility.
184{
185public:
187
188 QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) override;
189 QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) override;
190 QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize) override;
191 QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize) override;
192
193 virtual QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
194 virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize, const QQuickImageProviderOptions &options);
195 virtual QQuickTextureFactory *requestTexture(const QString &id, QSize *size, const QSize &requestedSize, const QQuickImageProviderOptions &options);
196 virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize, const QQuickImageProviderOptions &options);
197
198 static QSize loadSize(const QSize &originalSize, const QSize &requestedSize, const QByteArray &format, const QQuickImageProviderOptions &options,
199 qreal devicePixelRatio = 1.0);
200 static QQuickImageProviderWithOptions *checkedCast(QQuickImageProvider *provider);
201};
202
204
205#endif // QQUICKPIXMAP_H
IOBluetoothDevice * device
[qjs-as-container]
\inmodule QtCore
Definition qbytearray.h:57
The QColorSpace class provides a color space abstraction.
Definition qcolorspace.h:21
\inmodule QtCore \reentrant
Definition qiodevice.h:34
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:103
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
ImageType
Defines the type of image supported by this image provider.
Definition qqmlengine.h:21
The QQuickAsyncImageProvider class provides an interface for asynchronous control of QML image reques...
QImage image() const override
Returns an image version of this texture.
QSize textureSize() const override
Returns the size of the texture.
int textureByteCount() const override
Returns the number of bytes of memory the texture consumes.
QQuickDefaultTextureFactory(const QImage &i)
QSGTexture * createTexture(QQuickWindow *window) const override
This function is called on the scene graph rendering thread to create a QSGTexture instance from the ...
The QQuickImageProviderOptions class provides options for QQuickImageProviderWithOptions image reques...
AutoTransform
Whether the image provider should apply transformation metadata on read().
QQuickImageProvider::ImageType type
QQuickImageProvider::Flags flags
The QQuickImageProvider class provides an interface for supporting pixmaps and threaded image request...
The QQuickImageResponse class provides an interface for asynchronous image loading in QQuickAsyncImag...
static const QLatin1String itemGrabberScheme
The QQuickTextureFactory class provides an interface for loading custom textures from QML....
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtQuick
Definition qsgtexture.h:20
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
b clear()
p1 load("image.bmp")
rect
[4]
Combined button and popup list for selecting options.
Definition image.cpp:4
#define Q_DECLARE_TR_FUNCTIONS(context)
DBusConnection const char DBusError * error
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
Flags
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei width
GLenum type
GLbitfield flags
GLint GLsizei GLsizei GLenum format
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define Q_OBJECT
double qreal
Definition qtypes.h:187
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QFrame frame
[0]
imageLabel setPixmap(QPixmap::fromImage(image))
QJSEngine engine
[0]