zoukankan
html css js c++ java
常用的GDI+ 函数使用例子
一、通过Gdi+加载和显示PNG,JPG等格式的图片
//直接加载外部的图像
Image* image = new Image(L"test.png"); //如果需要通过ID 来加载的话
BOOL CSmalltmpdemoDlg::ImageFromIDResource(UINT nID, LPCTSTR sTR, Image * & pImg) { HINSTANCE hInst = AfxGetResourceHandle(); HRSRC hRsrc = ::FindResource (hInst,MAKEINTRESOURCE(nID),sTR); // type if (!hRsrc) return FALSE; // load resource into memory DWORD len = SizeofResource(hInst, hRsrc); BYTE* lpRsrc = (BYTE*)LoadResource(hInst, hRsrc); if (!lpRsrc) return FALSE; // Allocate global memory on which to create stream HGLOBAL m_hMem = GlobalAlloc(GMEM_FIXED, len); BYTE* pmem = (BYTE*)GlobalLock(m_hMem); memcpy(pmem,lpRsrc,len); IStream* pstm; CreateStreamOnHGlobal(m_hMem,FALSE,&pstm); // load from stream pImg=Gdiplus::Image::FromStream(pstm); // free/release stuff GlobalUnlock(m_hMem); pstm->Release(); FreeResource(lpRsrc); return TRUE; }
//调用方式
Image * pImage = NULL; ImageFromIDResource(IDR_PNG_NO_PIC, L"png", pImage); delete pImage; ///////////////////////////////////////////////////////////////////////// Image * pImage = NULL; ImageFromIDResource(IDR_PNG_NO_PIC, L"jpg", pImage); delete pImage; ////////////////////////////////////////////////////////////////////////// Image * pImage = NULL; ImageFromIDResource(IDR_PNG_NO_PIC, L"bitmap", pImage); delete pImage;
二、实现一个渐变的画刷
CClientDC dc(this); CRect rect; //获得当前客户区的大小 GetClientRect(&rect); //创建Graphics对象 Graphics graphics(dc); //创建渐变画刷 LinearGradientBrush lgb(Point(0, 0), Point(rect.right, rect.bottom), Color ::Blue, Color::Green); //填充 graphics.FillRectangle(&lgb, 0, 0, rect.right, rect.bottom);
查看全文
相关阅读:
能飞英语学习软件学习实践
英语学习方式总结与实践
Hello World
centos 7.6中搭建samba共享服务
PHP漏洞全解(一)PHP网站的安全性问题
MySQL查询语句练习题
在PHP中使用CURL实现GET和POST请求的方法
js数组的操作大全
php四种基础算法:冒泡,选择,插入和快速排序法
Linux查看端口使用状态及启动
原文地址:https://www.cnblogs.com/javawebsoa/p/2458419.html
最新文章
【mysql 】sql删除重复记录 You can't specify target table '表名' for update in FROM clause
java 之断言
spring 方法注入、方法替换
axios 模拟同步请求
vue项目post、put、delete、get向java后端传数组
springboot-security 登录 403
spring创建bean异常
shiro遇到的坑-重写sessionManager遇到的坑
vue-生命周期
vue-指令
热门文章
springcloud学习
秒数转时分秒显示格式
解决@WebServlet404的问题
MySQL忘记root密码重置密码(5.7版本)
websocket兼容IE8
Ubuntu连接MySql报错“can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock'”
putty上传文件到服务器失败:open for write: failure
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
'dataSource' or 'jdbcTemplate' is required异常
解决手机网页字段过长导致页面混乱
Copyright © 2011-2022 走看看