#include <GdiPlus.h>
#pragma comment(lib, "GdiPlus.lib")
using namespace Gdiplus;

class mygdiplus
{
  GdiplusStartupInput gdiplusStartupInput;
  ULONG_PTR gdiplusToken;
public:
  mygdiplus()
  {
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
  }
  ~mygdiplus()
  {
    GdiplusShutdown(gdiplusToken);
  }
}; Rect rect(20, 20, 326, 326);
Graphics grpx(hdc);
Image* pImage = new Image(TEXT("a1.png"));
//Image* pImage = Gdiplus::Image::FromFile(TEXT("a1.png"));
grpx.DrawImage(pImage,rect);
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps); /*Image image(L"a1.png");
Graphics graphics(hdc);
graphics.DrawImage(&image, 0, 0);*/ //GdiplusStartupInput gdiplusStartupInput;
//ULONG_PTR gdiplusToken;
//GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Rect rect(, , , );
Graphics grpx(hdc);
Image* pImage = new Image(TEXT("a1.png"));
//Image* pImage = Gdiplus::Image::FromFile(TEXT("a1.png"));
grpx.DrawImage(pImage,rect); delete pImage; // shut down - only once per process
//GdiplusShutdown(gdiplusToken); EndPaint(hWnd, &ps);
return ;
#include <windows.h>
#include <GdiPlus.h>
#pragma comment(lib, "GdiPlus.lib")
using namespace Gdiplus; class mygdiplus
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
public:
mygdiplus()
{
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
}
~mygdiplus()
{
GdiplusShutdown(gdiplusToken);
}
}; LRESULT CALLBACK MyWinMain(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);//回调函数(消息的) class cWNDCLASSEX
{
public:
cWNDCLASSEX(HINSTANCE h, int n) :hInstance(h), nCmdShow(n) {};
//WNDCLASSEX wndclass;
void cj();
private:
int nCmdShow;
HINSTANCE hInstance;
//WNDCLASSEX wndclass; }; void cWNDCLASSEX::cj()
{
WNDCLASSEX wndclass;
HBRUSH hBrush = ::CreateSolidBrush(RGB(, , ));
HWND hWnd;
wndclass.cbClsExtra = ;
wndclass.cbSize = sizeof(wndclass);
wndclass.cbWndExtra = ;
wndclass.hbrBackground = hBrush;
wndclass.hCursor = ;
wndclass.hIcon = ;
wndclass.hIconSm = ;
wndclass.lpfnWndProc = MyWinMain;
wndclass.lpszClassName = TEXT("Leo"); //注册窗口时候要的名字,作为参数
wndclass.lpszMenuName = ; //菜单名字
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.hInstance = hInstance; if (RegisterClassEx(&wndclass) == false)
{
//MessageBox(NULL, "注册失败", "提示", MB_OK);
//return 0;
} hWnd = CreateWindow(
TEXT("Leo"),
TEXT("Small Test"),
WS_OVERLAPPEDWINDOW|WS_VSCROLL,
,
,
,
,
NULL,
NULL,
hInstance,
NULL); ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
MSG msg;
while (::GetMessage(&msg, , , ))
{ ::TranslateMessage(&msg); //将得到的消息翻译
::DispatchMessage(&msg); //翻译来的消息发送 } } int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
cWNDCLASSEX a1(hInstance, nCmdShow);
a1.cj();
return ;
} LRESULT CALLBACK MyWinMain(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)//回调函数(消息的)
{
//HBRUSH m_hbr = CreateSolidBrush(RGB(255, 0, 0));
HDC hdc; //设备描述表句柄
PAINTSTRUCT ps;//绘制窗口
//RECT rect;
mygdiplus mygdiplusS;
switch(uMsg)
{ case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps); /*Image image(L"a1.png");
Graphics graphics(hdc);
graphics.DrawImage(&image, 0, 0);*/ //GdiplusStartupInput gdiplusStartupInput;
//ULONG_PTR gdiplusToken;
//GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); Rect rect(, , , );
Graphics grpx(hdc);
Image* pImage = new Image(TEXT("a1.png"));
//Image* pImage = Gdiplus::Image::FromFile(TEXT("a1.png"));
grpx.DrawImage(pImage,rect); delete pImage; // shut down - only once per process
//GdiplusShutdown(gdiplusToken); EndPaint(hWnd, &ps);
return ; }
case WM_CLOSE: //自动退出 ::PostQuitMessage();
break; } return DefWindowProc(hWnd, uMsg, wParam, lParam); //返回消息的默认处理
}

GDI+ 加载PNG图片的更多相关文章

  1. VB6之GDI+加载PNG图片

    原生的VB6不支持PNG个图片,因为刚有VB的时候还没有PNG的概念呢.不过,利用GDI+加载解析个PNG简直是砍瓜切菜般简单. GDI+的模块是我在网上下载的,地址应该是:http://vistas ...

  2. win32用GDI+加载png图片作为背景图

    #include <windows.h> #include <gdiplus.h> /* GDI+ startup token */ ULONG_PTR gdiplusStar ...

  3. VC中使用GDI+实现为按钮加载Png图片

    http://blog.csdn.net/flyfish1986/article/details/5381605 VC中使用GDI+实现为按钮加载Png图片 http://www.codeprojec ...

  4. WebView加载HTML图片大小自适应与文章自动换行

    http://www.brighttj.com/ios/ios-webview-load-html-image-adaptive.html 在很多App中都会使用到webview,尤其是在加载新闻内容 ...

  5. Android ListView 图片异步加载和图片内存缓存

    开发Android应用经常需要处理图片的加载问题.因为图片一般都是存放在服务器端,需要联网去加载,而这又是一个比较耗时的过程,所以Android中都是通过开启一个异步线程去加载.为了增加用户体验,给用 ...

  6. WPF中加载高分辨率图片性能优化

    在最近的项目中,遇到一个关于WPF中同时加载多张图片时,内存占用非常高的问题. 问题背景: 在一个ListView中同时加载多张图片,注意:我们需要加载的图片分辨率非常高. 代码: XAML: < ...

  7. Fresco 使用笔记(一):加载gif图片并播放

    项目总结 --------------------------------------------------------------------- 前言: 项目中图文混合使用的太多太多了,但是绝大部 ...

  8. 图片_ _Android有效解决加载大图片时内存溢出的问题 2

    Android有效解决加载大图片时内存溢出的问题 博客分类: Android Android游戏虚拟机算法JNI 尽量不要使用setImageBitmap或 setImageResource或 Bit ...

  9. Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子

    Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子 procedure TForm1.Button1Click(Sender: TObject); ...

随机推荐

  1. Ubuntu 16.04安装双显卡驱动方法收集

    说明:不一定有效,要不断尝试. http://www.linuxwang.com/html/2150.html http://blog.csdn.net/feishicheng/article/det ...

  2. flash update

    https://get.adobe.com/cn/flashplayer/otherversions/

  3. sklearn特征工程总结

    转自: http://www.cnblogs.com/jasonfreak/p/5448385.html https://www.zhihu.com/question/28641663/answer/ ...

  4. 九度OJ1004 Median

    题目描写叙述: Given an increasing sequence S of N integers, the median is the number at the middle positio ...

  5. SQL 主机

    SQL 主机 SQL 主机 如果您想要您的网站存储数据在数据库并从数据库显示数据,您的 Web 服务器必须能使用 SQL 语言访问数据库系统. 如果您的 Web 服务器托管在互联网服务提供商(ISP, ...

  6. hdu 5087 Revenge of LIS II ( LIS ,第二长子序列)

    链接:hdu 5087 题意:求第二大的最长升序子序列 分析:这里的第二大指的是,全部的递增子序列的长度(包含相等的), 从大到小排序后.排在第二的长度 cid=546" style=&qu ...

  7. android KE or NE分析

    使用arm-eabi-addr2line工具跟踪Android调用堆栈 在通常的C/C++代码中,可以通过响应对内存操作不当引起的Segmentation Fault错误即信号SIGSEGV(11)做 ...

  8. libevent API 介绍

    基本应用场景也是使用 libevnet 的基本流程,下面来考虑一个最简单的场景,使用livevent 设置定时器,应用程序只需要执行下面几个简单的步骤即可. 1)首先初始化 libevent 库,并保 ...

  9. java 生成压测数据

    询价接口压测,需要批量生成数据, 数据包括4个字段(车牌号,车架号,发动机号,支付号)licenseNo,vehicleFrameNo,engineNo,payFlowId 需符合LoadRunner ...

  10. [Spring实战系列](19)Servlet不同版本号之间的差别

    1.   2.3版本号 2.3版本号 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application ...