Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowsdirect2dplatformpixmap.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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
9
10#include <QtGui/qpainter.h>
11#include <QtGui/qimage.h>
12#include <QtGui/qpaintdevice.h>
13#include <QtGui/qpaintengine.h>
14
16
18{
19public:
21 : owns_bitmap(true)
24 {}
25
28 : bitmap(bitmap)
30 {}
31
33 {
34 if (owns_bitmap)
35 delete bitmap;
36 }
37
38 bool owns_bitmap = false;
42};
43
44static int qt_d2dpixmap_serno = 0;
45
47 : QPlatformPixmap(pixelType, Direct2DClass)
49{
51}
52
56 : QPlatformPixmap(pixelType, Direct2DClass)
58{
60
61 is_null = false;
62 w = bitmap->size().width();
63 h = bitmap->size().height();
64 this->d = 32;
65}
66
68{
69
70}
71
73{
75
76 if (!d->bitmap->resize(width, height)) {
77 qWarning("%s: Could not resize bitmap", __FUNCTION__);
78 return;
79 }
80
81 is_null = false;
82 w = width;
83 h = height;
84 this->d = 32;
85}
86
88 Qt::ImageConversionFlags flags)
89{
91
92 if (!d->bitmap->fromImage(image, flags)) {
93 qWarning("%s: Could not init from image", __FUNCTION__);
94 return;
95 }
96
97 is_null = false;
98 w = image.width();
99 h = image.height();
100 this->d = 32;
101}
102
104{
106 return qt_paint_device_metric(d->device.data(), metric);
107}
108
110{
112 d->bitmap->fill(color);
113}
114
116{
117 return true;
118}
119
121{
122 return toImage(QRect());
123}
124
126{
128
129 QWindowsDirect2DPaintEngineSuspender suspender(static_cast<QWindowsDirect2DPaintEngine *>(d->device->paintEngine()));
130 return d->bitmap->toImage(rect);
131}
132
134{
136 return d->device->paintEngine();
137}
138
140{
142 return d->devicePixelRatio;
143}
144
146{
148 d->devicePixelRatio = scaleFactor;
149}
150
152{
154 return d->bitmap;
155}
156
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtGui
Definition qimage.h:37
\inmodule QtGui
The QPlatformPixmap class provides an abstraction for native pixmaps.
int height() const
void setSerialNumber(int serNo)
int width() const
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
QWindowsDirect2DPlatformPixmapPrivate(QWindowsDirect2DBitmap *bitmap, QWindowsDirect2DPaintEngine::Flags flags)
QScopedPointer< QWindowsDirect2DPaintDevice > device
void fromImage(const QImage &image, Qt::ImageConversionFlags flags) override
void resize(int width, int height) override
void setDevicePixelRatio(qreal scaleFactor) override
void fill(const QColor &color) override
QPaintEngine * paintEngine() const override
int metric(QPaintDevice::PaintDeviceMetric metric) const override
rect
[4]
Combined button and popup list for selecting options.
Definition image.cpp:4
#define qWarning
Definition qlogging.h:162
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLint GLsizei width
GLbitfield flags
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric)
XID Pixmap
double qreal
Definition qtypes.h:92
static int qt_d2dpixmap_serno