绘制WICBitmap到窗口
Draw WICBitmap to window?
我有一个WICBitmap
,在我的MFC程序中包含一个图像。有没有办法把这个位图画到设备上下文上?
void DrawBitmap(IWICBitmapSource source, HDC targetDC, int X, int Y, int cx, int cy)
{
//source: The Bitmap to draw
//TargetDC: The HDC to draw onto (e.g. a printer or screen DC)
//X,Y: The location on the DC to draw the bitmap
}
MSDN上有许多示例,展示了如何使用GDI, GDI+, Direct2D等显示WIC位图。
- MSDN:图像解码样本(存档)
- WIC简介:如何使用WIC加载图像,并使用GDI绘制图像?(归档)
Microsoft提供了一个使用GDI示例的WIC图像查看器(GitHub镜像)
基本思想是:
- 将IWicBitmapSource转换为标准的Windows BITMAP(
CreateDibSectionFromBitmapSource
) - 使用位图绘制使用您的标准工具
该文件可以单独编辑为bmp文件,加载WIC对象后,您可以看到如何从文件加载位图
相关文章:
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 问:如何使用C++中的按钮从窗口打开窗口
- SDL 窗口不会弹出
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- 如何在cpp文件之间切换窗口?在Qt中
- QuadTree只在窗口的右上角绘制
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 如何在C++中找到active directory中禁用和锁定的窗口帐户
- 处理闪烁窗口事件
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- C++win32 API创建多个类似视口的窗口
- SFML RenderWindow打开窗口需要很长时间
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 获取 SFML 窗口的 HWND 和高可用性?
- 如何获取 GLFW 窗口 ID?
- GLEW/GLUT:调用init并创建一个窗口后,取消初始化并重新初始化?
- 用于窗口的 HID 终端
- SFML 文本未绘制在窗口上
- 如何为窗口截屏
- 绘制WICBitmap到窗口