将png资源加载到CBitMap [英] Load a png resource into a CBitMap

查看:530
本文介绍了将png资源加载到CBitMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将png资源载入CBitMap?
当我尝试这个不工作。

How do i load a png resource into a CBitMap? When i try this it doesnt work.

CImage image;
image.LoadFromResource(AfxGetInstanceHandle(), IDB_PNG1);
bitmap.Attach(image.Detach());

它给我一个错误资源类型未找到。是否有其他方法加载PNG资源?

It gives me an error resource type not found. Is there any other way to load a PNG resource?

推荐答案

如果您使用VS2008或更新版本使用来自 CBitmap 并且包含在< afxtoolbarimages.h>中的 CPngImage code>

If you are using VS2008 or newer (MFC Feature Pack) you can use CPngImage which derives from CBitmap and is contained in <afxtoolbarimages.h>

CPngImage image;
image.Load(AfxGetInstanceHandle(), IDB_PNG1);
bitmap.Attach(image.Detach());

这篇关于将png资源加载到CBitMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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