心胸决定格局,眼界决定境界...

采用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);

}

posted @ 2013-11-26 15:57  WELEN  阅读(590)  评论(0)    收藏  举报