采用GDI+绘制PNG
I、png.h
#include <GdiPlus.h>
using namespace Gdiplus;
#pragma comment(lib,"GdiPlus.lib")
//采用GDI+绘制png格式图片
class PNG
{
private:
ULONG_PTR token;
public:
PNG();
void draw(WCHAR* path,HDC &hdc,int x,int y,int cx,int cy);
~PNG();
};
II、png.cpp
#include "stdafx.h"
#include "png.h"
//PNG
PNG::PNG()
{
GdiplusStartupInput in;
GdiplusStartup(&token,&in,NULL);
}
PNG::~PNG()
{
GdiplusShutdown(token);
}
void PNG::draw(WCHAR* path,HDC &hdc,int x,int y,int cx,int cy)
{
Graphics g(hdc);
Image im(path,false);
g.DrawImage(&im,x,y,cx,cy);
}

浙公网安备 33010602011771号