来自HBITMAP的QImage [英] QImage from HBITMAP

查看:764
本文介绍了来自HBITMAP的QImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在仅Windows程序中,我使用第三方库,该库返回HBITMAP.

In my windows-only program, I use a third-party library, which returns a HBITMAP.

是否可以从其内容初始化QImage,即将其转换为QImage?

Is there a way to initialize a QImage from its contents, i.e. to convert it to a QImage?

推荐答案

这是Qt 4(QtGui)的解决方法:

This is the way to do it for Qt 4 (QtGui):

QImage image(QPixmap::fromWinHBITMAP(hBitmap).toImage());

这是Qt 5(QtWinExtras)的一种实现方法:

This is the way to do it for Qt 5 (QtWinExtras):

QPixmap pixmap = QtWin::fromHBITMAP(hBitmap);
QImage image = pixmap.toImage();

// or

QtWin::imageFromHBITMAP(hdc, hBitmap, width, height)

这篇关于来自HBITMAP的QImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆