8#include <QtGui/qwindow.h>
9#include <QtGui/qpainter.h>
10#include <QtGui/private/qwindowsnativeimage_p.h>
11#include <private/qhighdpiscaling_p.h>
12#include <private/qimage_p.h>
14#include <QtCore/qdebug.h>
26 m_alphaNeedsFill(
false)
33 qCDebug(lcQpaBackingStore) << __FUNCTION__ <<
this;
39 return &m_image->
image();
62 POINT ptDst = {
r.x(),
r.y()};
64 BLENDFUNCTION blend = {AC_SRC_OVER, 0, BYTE(
qRound(255.0 * rw->
opacity())), AC_SRC_ALPHA};
65 RECT dirty = {dirtyRect.
x(), dirtyRect.
y(),
66 dirtyRect.
x() + dirtyRect.
width(), dirtyRect.
y() + dirtyRect.
height()};
67 UPDATELAYEREDWINDOWINFO
info = {
sizeof(
info),
nullptr, &ptDst, &
size,
68 m_image->
hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty};
71 qErrnoWarning(
"UpdateLayeredWindowIndirect failed for ptDst=(%d, %d),"
72 " size=(%dx%d), dirty=(%dx%d %d, %d)",
r.x(),
r.y(),
74 dirtyRect.
x(), dirtyRect.
y());
76 const HDC dc = rw->
getDC();
84 const DWORD lastError = GetLastError();
85 if (lastError != ERROR_SUCCESS && lastError != ERROR_INVALID_HANDLE)
86 qErrnoWarning(
int(lastError),
"%s: BitBlt failed", __FUNCTION__);
104#ifndef QT_NO_DEBUG_OUTPUT
107 << __FUNCTION__ <<
' ' <<
window() <<
' ' <<
size <<
' ' << region
118 m_alphaNeedsFill =
true;
125 if (oldwni && !region.
isEmpty()) {
127 QImage &newimg(newwni->image());
137 m_image.
reset(newwni);
158 qCDebug(lcQpaBackingStore) <<__FUNCTION__ << region;
160 if (m_alphaNeedsFill) {
164 for (
const QRect &
r : region)
165 p.fillRect(
r, blank);
172 return m_image->
hdc();
179 qCWarning(lcQpaBackingStore) <<__FUNCTION__ <<
"Image is null.";
The QColor class provides colors based on RGB, HSV or CMYK values.
static QPixelFormat toPixelFormat(QImage::Format format) noexcept
Converts format into a QPixelFormat.
QSize size() const
Returns the size of the image, i.e.
int width() const
Returns the width of the image.
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
Saves the image to the file with the given fileName, using the given image file format and quality fa...
bool isNull() const
Returns true if it is a null image, otherwise returns false.
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
@ Format_ARGB32_Premultiplied
constexpr int left() const noexcept
Returns the left margin.
constexpr int top() const noexcept
Returns the top margin.
The QPainter class performs low-level painting on widgets and other paint devices.
void setCompositionMode(CompositionMode mode)
Sets the composition mode to the given mode.
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...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
Returns the bounding rectangle of this region.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
bool isNull() const noexcept
Returns true if this object refers to \nullptr.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\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...
Qt::WindowFlags flags
the window flags of the window
QSurfaceFormat format() const override
Returns the actual format of this window.
void beginPaint(const QRegion &) override
This function is called before painting onto the surface begins, with the region in which the paintin...
~QWindowsBackingStore() override
QPaintDevice * paintDevice() override
Implement this function to return the appropriate paint device.
bool scroll(const QRegion &area, int dx, int dy) override
Scrolls the given area dx pixels to the right and dy downward; both dx and dy may be negative.
QWindowsBackingStore(QWindow *window)
void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override
Flushes the given region from the specified window.
void resize(const QSize &size, const QRegion &r) override
QImage toImage() const override
Implemented in subclasses to return the content of the backingstore as a QImage.
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
static QImage::Format systemFormat()
static QWindowsWindow * windowsWindowOf(const QWindow *w)
HDC getDC()
Allocates a HDC for the window or returns the temporary one obtained from WinAPI BeginPaint within a ...
static bool setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qreal opacity)
QSurfaceFormat format() const override
Returns the actual surface format of the window.
QMargins frameMargins() const override
void releaseDC()
Releases the HDC for the window or does nothing in case it was obtained from WinAPI BeginPaint within...
HWND handle() const override
void qErrnoWarning(const char *msg,...)
T toNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
static int area(const QSize &s)
QImage::Format qt_maybeAlphaVersionWithSameDepth(QImage::Format format)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define SIZE(large, small, mini)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
static bool hasAlpha(const QImage &image)
Q_GUI_EXPORT void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
QFileInfo info(fileName)
[8]