9#include <QtGui/qimage.h>
10#include <QtGui/qcolor.h>
22 ID2D1Bitmap1 *bm =
nullptr)
38 return D2D1::BitmapProperties1(
39 D2D1_BITMAP_OPTIONS_TARGET,
40 D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
41 D2D1_ALPHA_MODE_PREMULTIPLIED),
57 bitmap.ReleaseAndGetAddressOf());
61 qWarning(
"%s: Could not create bitmap: %#lx", __FUNCTION__, hr);
77 properties.bitmapOptions = D2D1_BITMAP_OPTIONS_CANNOT_DRAW | D2D1_BITMAP_OPTIONS_CPU_READ;
82 qWarning(
"%s: Could not create bitmap: %#lx", __FUNCTION__, hr);
86 hr = mappingCopy->CopyFromBitmap(
nullptr,
bitmap.Get(),
nullptr);
88 qWarning(
"%s: Could not copy from bitmap: %#lx", __FUNCTION__, hr);
92 D2D1_MAPPED_RECT mappedRect;
93 hr = mappingCopy->Map(D2D1_MAP_OPTIONS_READ, &mappedRect);
95 qWarning(
"%s: Could not map: %#lx", __FUNCTION__, hr);
99 return QImage(
static_cast<const uchar *
>(mappedRect.bits),
100 int(
size.width),
int(
size.height),
int(mappedRect.pitch),
140 return d->bitmap.Get();
146 return d->deviceContext.data();
153 d->deviceContext->begin();
155 d->deviceContext->end();
161 return d->toImage(
rect);
168 D2D1_SIZE_U
size =
d->bitmap->GetPixelSize();
The QColor class provides colors based on RGB, HSV or CMYK values.
qsizetype bytesPerLine() const
Returns the number of bytes per image scanline.
QImage copy(const QRect &rect=QRect()) const
Returns a sub-area of the image as a new image.
int width() const
Returns the width of the image.
int height() const
Returns the height of the image.
@ Format_ARGB32_Premultiplied
const uchar * constBits() const
Returns a pointer to the first pixel data.
\inmodule QtCore\reentrant
QImage toImage(const QRect &rect)
QScopedPointer< QWindowsDirect2DDeviceContext > deviceContext
D2D1_BITMAP_PROPERTIES1 bitmapProperties() const
bool resize(int width, int height, const void *data=nullptr, int pitch=0)
QWindowsDirect2DBitmapPrivate(ID2D1DeviceContext *dc=nullptr, ID2D1Bitmap1 *bm=nullptr)
ComPtr< ID2D1Bitmap1 > bitmap
QWindowsDirect2DDeviceContext * deviceContext() const
~QWindowsDirect2DBitmap()
void fill(const QColor &color)
ID2D1Bitmap1 * bitmap() const
bool resize(int width, int height)
bool fromImage(const QImage &image, Qt::ImageConversionFlags flags)
QImage toImage(const QRect &rect=QRect())
ID2D1Factory1 * d2dFactory() const
static QWindowsDirect2DContext * instance()
ID2D1DeviceContext * get() const
Combined button and popup list for selecting options.
#define QT_WARNING_DISABLE_DEPRECATED
static const QCssKnownValue properties[NumProperties - 1]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
D2D1::ColorF to_d2d_color_f(const QColor &c)