GDI+ 加载PNG图片
#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图片的更多相关文章
- VB6之GDI+加载PNG图片
原生的VB6不支持PNG个图片,因为刚有VB的时候还没有PNG的概念呢.不过,利用GDI+加载解析个PNG简直是砍瓜切菜般简单. GDI+的模块是我在网上下载的,地址应该是:http://vistas ...
- win32用GDI+加载png图片作为背景图
#include <windows.h> #include <gdiplus.h> /* GDI+ startup token */ ULONG_PTR gdiplusStar ...
- VC中使用GDI+实现为按钮加载Png图片
http://blog.csdn.net/flyfish1986/article/details/5381605 VC中使用GDI+实现为按钮加载Png图片 http://www.codeprojec ...
- WebView加载HTML图片大小自适应与文章自动换行
http://www.brighttj.com/ios/ios-webview-load-html-image-adaptive.html 在很多App中都会使用到webview,尤其是在加载新闻内容 ...
- Android ListView 图片异步加载和图片内存缓存
开发Android应用经常需要处理图片的加载问题.因为图片一般都是存放在服务器端,需要联网去加载,而这又是一个比较耗时的过程,所以Android中都是通过开启一个异步线程去加载.为了增加用户体验,给用 ...
- WPF中加载高分辨率图片性能优化
在最近的项目中,遇到一个关于WPF中同时加载多张图片时,内存占用非常高的问题. 问题背景: 在一个ListView中同时加载多张图片,注意:我们需要加载的图片分辨率非常高. 代码: XAML: < ...
- Fresco 使用笔记(一):加载gif图片并播放
项目总结 --------------------------------------------------------------------- 前言: 项目中图文混合使用的太多太多了,但是绝大部 ...
- 图片_ _Android有效解决加载大图片时内存溢出的问题 2
Android有效解决加载大图片时内存溢出的问题 博客分类: Android Android游戏虚拟机算法JNI 尽量不要使用setImageBitmap或 setImageResource或 Bit ...
- Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子
Delphi7 第三方控件1stClass4000的TfcImageBtn按钮控件动态加载jpg图片例子 procedure TForm1.Button1Click(Sender: TObject); ...
随机推荐
- Eclipse导入Maven项目出现:Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:2.2
错误如下: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-war-plugin:2.2 or one of ...
- 创立一个站点的前前后后(起因,域名,云平台,备案,CDN等等)(1)
起因 写完<完美软件开发:方法与逻辑>这书后,原本想继续写书的,可出来參加了些社区活动后,我发现我写的书大家评价还行.但事实上不太理解.而接下来想写的书更加抽象点.准备叫<管理的解析 ...
- ASP.NET没有魔法——ASP.NET MVC Razor与View渲染 ASP.NET没有魔法——ASP.NET MVC界面美化及使用Bundle完成静态资源管理
ASP.NET没有魔法——ASP.NET MVC Razor与View渲染 对于Web应用来说,它的界面是由浏览器根据HTML代码及其引用的相关资源进行渲染后展示给用户的结果,换句话说Web应用的 ...
- udhcp源码详解(三) 下 之配置信息的读取
上节讲解了read_config函数,读取配置信息到server_config的相应成员变量里,但read_config函数只负责把配置信息重文件里读出来,具体怎么把信息填写到指定的地址内,是调用ke ...
- 在云服务器 ECS Linux CentOS 7 下重启服务不再通过 service 操作,而是通过 systemctl 操作
在云服务器 ECS Linux CentOS 7 下重启服务不再通过 service 操作,而是通过 systemctl 操作. 操作说明如下: 1. 查看 sshd 服务是否启动: 看到上述信息就 ...
- 【内存数据库】OracleTimesten连接DSN创建用户
************************************************************************ ****原文:blog.csdn.net/clark_ ...
- Unable to find a team with the given Team ID或者Failed to code sign的问题解决
Unable to find a team with the given Team ID或者Failed to code sign的问题解决 1:问题描述(注:这种情况一般是下载并打开别人项目时) F ...
- Eclipse项目遇到问题汇总
1:gc overhead limit exceeded 原因:这是由于项目中eclipse内存分配不足导致 修改:修改eclipse.ini文件 修改如下: ...
- PyTorch 60 分钟入门教程:数据并行处理
可选择:数据并行处理(文末有完整代码下载) 作者:Sung Kim 和 Jenny Kang 在这个教程中,我们将学习如何用 DataParallel 来使用多 GPU. 通过 PyTorch 使用多 ...
- 【bzoj2753】[SCOI2012]滑雪与时间胶囊
#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> # ...