diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-03-17 13:33:50 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-04-18 08:01:54 +0000 |
commit | acb67561a3753306a2262f7221baca2d727fd4cb (patch) | |
tree | c890a9e7f90382bf60db4c22abc8f778d13a84f5 /src | |
parent | 7b267bd3858743af32c30dcbd84c0e5dc11da0ba (diff) |
Add imageToHBITMAP(), imageFromHBITMAP()
Add new functions for image conversions wrapping their QtGui
equivalents.
[ChangeLog][QtWin] Added functions imageToHBITMAP()
and imageFromHBITMAP() for conversion between QImage and HBITMAP,
preserving the format where possible.
Task-number: QTBUG-51124
Change-Id: I212b2dff182dce3a9b08753b6435d01b75bb5434
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/winextras/qwinfunctions.cpp | 31 | ||||
-rw-r--r-- | src/winextras/qwinfunctions.h | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/winextras/qwinfunctions.cpp b/src/winextras/qwinfunctions.cpp index 7b102a8..7089966 100644 --- a/src/winextras/qwinfunctions.cpp +++ b/src/winextras/qwinfunctions.cpp @@ -69,6 +69,8 @@ Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap); Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0); Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p); +Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat = 0); +Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h); Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); @@ -139,6 +141,22 @@ HICON QtWin::toHICON(const QPixmap &p) } /*! + \since 5.12 + + Creates a \c HBITMAP equivalent of the QImage \a image, + based on the given \a format. Returns the \c HBITMAP handle. + + It is the caller's responsibility to free the \c HBITMAP data + after use. + + \sa imageFromHBITMAP() +*/ +HBITMAP QtWin::imageToHBITMAP(const QImage &image, QtWin::HBitmapFormat format) +{ + return qt_imageToWinHBITMAP(image, format); +} + +/*! \since 5.2 Returns a QImage that is equivalent to the @@ -153,6 +171,19 @@ QImage QtWin::imageFromHBITMAP(HDC hdc, HBITMAP bitmap, int width, int height) } /*! + \since 5.12 + + Returns a QImage that is equivalent to the + given \a bitmap. The conversion is based on the specified \a format. + + \sa imageToHBITMAP() +*/ +QImage QtWin::imageFromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format) +{ + return qt_imageFromWinHBITMAP(bitmap, format); +} + +/*! \since 5.2 Returns a QPixmap that is equivalent to the given \a icon. diff --git a/src/winextras/qwinfunctions.h b/src/winextras/qwinfunctions.h index bc07401..fe461d1 100644 --- a/src/winextras/qwinfunctions.h +++ b/src/winextras/qwinfunctions.h @@ -81,7 +81,9 @@ namespace QtWin Q_WINEXTRAS_EXPORT HBITMAP toHBITMAP(const QPixmap &p, HBitmapFormat format = HBitmapNoAlpha); Q_WINEXTRAS_EXPORT QPixmap fromHBITMAP(HBITMAP bitmap, HBitmapFormat format = HBitmapNoAlpha); Q_WINEXTRAS_EXPORT HICON toHICON(const QPixmap &p); + Q_WINEXTRAS_EXPORT HBITMAP imageToHBITMAP(const QImage &image, QtWin::HBitmapFormat format = HBitmapNoAlpha); Q_WINEXTRAS_EXPORT QImage imageFromHBITMAP(HDC hdc, HBITMAP bitmap, int width, int height); + Q_WINEXTRAS_EXPORT QImage imageFromHBITMAP(HBITMAP bitmap, QtWin::HBitmapFormat format = HBitmapNoAlpha); Q_WINEXTRAS_EXPORT QPixmap fromHICON(HICON icon); Q_WINEXTRAS_EXPORT HRGN toHRGN(const QRegion ®ion); Q_WINEXTRAS_EXPORT QRegion fromHRGN(HRGN hrgn); |