简体   繁体   English

从Win32项目中的* .bmp文件加载HBITMAP

[英]Load HBITMAP from *.bmp file in Win32 project

是否可以仅使用WINAPI函数将* .bmp文件加载到Win32项目中的HBITMAP中?

Yes, it is possible using only the standard win32 library. 是的,可以仅使用标准的win32库。

HBITMAP hBMP = (HBITMAP) LoadImage( NULL, "Your/ImagePath/a.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

hBMP is a handle to the BITMAP to use as you want. hBMP是要使用的BITMAP的句柄。

Note: It is important to pass NULL as the first argument, from the docs: 注意:重要的是从docs传递NULL作为第一个参数:

hinst [in, optional] 隐身[in,可选]

To load a stand-alone resource (icon, cursor, or bitmap file)—for example, c:\\myimage.bmp—set this parameter to NULL. 要加载独立资源(图标,光标或位图文件)(例如c:\\ myimage.bmp),请将此参数设置为NULL。

From the msdn documentation for LoadImage . msdn有关LoadImage文档中

Yes, you can use the OleLoadPictureFromPath or whatever it was called. 是的,您可以使用OleLoadPictureFromPath或任何它所谓的名称。 Check it. 检查。 The docs are probably still inconsistent and wrong about supported formats but in modern Windows also JPEG and PNG supported. 该文档可能仍然不一致,并且关于支持的格式有误,但是在现代Windows中还支持JPEG和PNG。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM