- 1、本文档共21页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
vc显示图像(VC display images)
vc显示图像(VC display images)
Used VC people know VC image display as VB is convenient, online introduces many methods to achieve, the long code that many beginners deterred forgotten. To do this, I encapsulate the following code in a function (with a strong mobility value) for your reference. When you call the function, just give the file name of the picture, the HWND of the output window, and the size of the image shown (the size of the actual image you want to zoom in or out of).
#include ocidl.h
#include olectl.h
/ / lpstrFile: file name (best path included)
/ / hWnd
NScrWidth: / / output picture width
The height of the image output: / / nScrHeight
NScrWidth, nScrHeight / / is the actual size of the output image, it refers to the zoom size after
HRESULT, ShowPic (char, *lpstrFile, HWND, hWnd, int, nScrWidth, int, nScrHeight)
{
HDC hDC_Temp=GetDC (hWnd);
IPicture *pPic;
IStream *pStm;
BOOL bResult;
HANDLE hFile=NULL;
DWORD, dwFileSize, dwByteRead;
Open / hard disk in the graphics file
HFile=CreateFile (lpstrFile, GENERIC_READ),
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
If (hFile, =INVALID_HANDLE_value)
{
DwFileSize=GetFileSize (hFile, NULL); / / get the file number of bytes
If (dwFileSize==0xFFFFFFFF)
Return E_FAIL;
}
Else
{
Return E_FAIL;
}
/ / global storage space allocation
HGLOBAL hGlobal = GlobalAlloc (GMEM_MOVEABLE, dwFileSize);
LPVOID pvData = NULL;
If (hGlobal = NULL)
Return E_FAIL;
If ((pvData = GlobalLock (hGlobal)) = = NULL) / / lock memory block allocation
Return E_FAIL;
ReadFile (hFile, pvData, dwFileSize, dwByteRead, NULL); / / put the file into memory buffer
GlobalUnlock (hGlobal);
CreateStreamOnHGlobal (hGlobal, TRUE, pStm);
/ / load graphics file
BResult=OleLoadPicture (pStm, dwFileSize, TRUE, IID_IPicture, (LPVOID*) pPic);
If (FAILED (bResult))
Return E_FAIL;
OLE_XSIZE_HIMETRIC hmWidth; / / true picture width
OLE_YSIZE_HIMETRIC hmHeight; / / true picture
PPic-get_Width (hmWidth);
PPic-get_Height (hmHeight);
/ / graphics out
您可能关注的文档
- rotax发动机性能(Rotax engine performance).doc
- s4新赛季排位个人上分心得 游戏的理解(S4 new season qualifying personal experience game understanding).doc
- s4如何打好定级赛 详谈lol里的伤害计算(S4 how to play the grading game, talk about the damage calculation in lol).doc
- s700k集中检修(S700K centralized maintenance).doc
- s7200以太网(S7200 Ethernet).doc
- rim数字营销主管理管沃雷斯跳槽三星移动(Rim Digital Marketing Manager Wallace Samsung mobile switch tube).doc
- sap2000学习心得与问题(SAP2000 learning experiences and problems).doc
- sap2000线性和非线性(SAP2000 linear and nonlinear).doc
- sci论文摘要中常用的表达方法(Expressions commonly used in SCI Abstract).doc
- scp-682(scp-682).doc
文档评论(0)