gpt4 book ai didi

winapi - 有没有办法在不使用 MFC 的情况下在窗口上绘制 PNG 图像?

转载 作者:行者123 更新时间:2023-12-04 17:05:37 25 4
gpt4 key购买 nike

我正在开发 Windows API应用程序不使用 MFC .
我正在使用标准的 Windows 库。

如何在窗口中绘制 PNG 图像?

帮我提供一些示例代码。

我尝试了一些在 Internet 上可用的代码,但都使用 MFC。

最佳答案

看看this StackOverflow question .它提供了多种选项,可以满足您的需求。

改编自 MSDN :

#include <windows.h>
#include <gdiplus.h>
#include <stdio.h>
using namespace Gdiplus;

void draw()
{
// start up GDI+ -- only need to do this once per process at startup
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);


Rect rect(20,20,50,50);
Graphics grpx(dc);
Image* image = new Image(L"SomePhoto.png");
grpx.DrawImage(Img,rect);

delete image;

// shut down - only once per process
GdiplusShutdown(gdiplusToken);
return;
}

关于winapi - 有没有办法在不使用 MFC 的情况下在窗口上绘制 PNG 图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1905476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com