在QT5中从QPixmap获取HBITMAP(Windows) [英] Getting a HBITMAP from a QPixmap in QT5 (Windows)

查看:1047
本文介绍了在QT5中从QPixmap获取HBITMAP(Windows)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在不建议使用QPixmap :: toWinHBITMAP(),我找不到从QPixmap(或QImage)获取HBITMAP的方法.

Now that QPixmap::toWinHBITMAP() has been deprecated, I can't find a way to get an HBITMAP from a QPixmap (or QImage).

谷歌搜索,我发现有一个名为qt_pixmapToWinHBITMAP()的函数似乎可以满足我的需要,但是我找不到在.pro文件中应该启用的模块(如果有的话)或应该包含的头文件它,或者其他的东西.

Googling, I found there's a function called qt_pixmapToWinHBITMAP() which seems would do what I need, but I can't find what module I should enable -if any- in my .pro file or what header I should include to use it, or perhaps something else.

我需要HBITMAP的原因是使用VFW创建视频.当然,我很乐意仅使用Qt就能做到这一点.有QtMultimedia模块,但据我所知它不会导出视频,所以我想我一直坚持直接使用Windows api.

The reason I need a HBITMAP is to create a video using VFW. Of course, I'd love to be able to do that using only Qt. There's the QtMultimedia module, but as far as I can tell it doesn't export video, so I guess I'm stuck with using the windows api directly.

任何帮助将不胜感激.

推荐答案

我找到了!

我需要的只是QtWinExtras

All I needed was QtWinExtras

http://qt.gitorious.org/qt/qtwinextras

我的代码现在看起来像这样:

My code now looks something like this:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <qt_windows.h>
#include <QtWinExtras/QWinFunctions>


...
QPixmap pix(QSize(w,h));
...
HBITMAP hbm = QWinExtras::toHBITMAP(pix);
...
::DeleteObject(hbm);

我不知道是否需要包含所有这些标头,但是它对我有用.

I don't know if I need to include all those headers, but it works for me.

这篇关于在QT5中从QPixmap获取HBITMAP(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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