如何使用LoadImage和StretchDIBits绘制PNG图像? [英] How would I draw a PNG image using LoadImage and StretchDIBits?
问题描述
(这与如何使用Win32 / GDI加载PNG图像(如果可能,不加GDI +)?。
大家好,
我想知道,鉴于您的PNG资源嵌入了ID为 IDB_PNG1
的二进制文件中,并且要绘制的 LPDRAWITEMSTRUCT
(这意味着你有 HDC
和目标的矩形),你如何绘制使用 StretchDIBits
将该图像放到屏幕上?我之前使用 BitBlt
和 TransparentBlt
,但是 StretchDIBits
似乎工作方式不同, LoadImage
似乎不适用于PNG。
I was wondering, given that you have a PNG resource embedded in a binary file with the ID IDB_PNG1
, and an LPDRAWITEMSTRUCT
to draw into (so that means you have the HDC
and the rectangle for your target), how do you draw that image onto the screen using StretchDIBits
? I've worked with BitBlt
and TransparentBlt
before, but StretchDIBits
seems to work differently, and LoadImage
doesn't seem to work with PNG's.
谢谢!
(注意:我说的语言是C ++,但这不太重要...... C,C#,Visual Basic等都没关系;我只是想尝试找出步骤,而不是所需的确切代码。)
(Note: The language I put is C++, but that's not too important... C, C#, Visual Basic, etc. would be fine; I'm just trying to figure out the steps, not the exact code needed.)
推荐答案
我认为位图内的PNG支持只适用于打印机驱动。对于屏幕显示,您可能需要使用某些代码自行解压缩PNG数据,例如 libpng 。
I think the PNG support inside bitmaps is only really for use by printer drivers. For screen display, you will probably have to decompress the PNG data yourself using some code such as libpng.
这篇关于如何使用LoadImage和StretchDIBits绘制PNG图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!