最新消息:

OleLoadPicturePath在NSIS中如何改变远程图片的显示大小

nsis 永恒心锁 1902浏览 0评论
/*
OleLoadPicturePath在NSIS中如何改变远程图片的显示大小
OleLoadPicturePath支持BMP(bitmap),JPEG,WMF,ICO(图标),GIF动画这几种格式.不支持PNG.
IPTR->IDXMember indexed IDX from interface pointed by IPTR这个表接口数字可以到头文件定义里去找
如:IPicture->get_Handle就是定义在typedef struct IPictureVtbl这个结构体里,标号从0开始.
*/
!ifndef IID_IPicture
 !define IID_IPicture {7BF80980-BF32-101A-8BBB-00AA00300CAB}
!endif
!define S_OK 0x000000
!define SRCCOPY 0xCC0020
!include nsDialogs.nsh
!define IMAGEPATH "http://nsis.sourceforge.net/mediawiki/skins/nsis/logo.gif" ;"C:WindowsWebWallpaperWindowsimg0.jpg"
!define NEWSIZEW 200
!define NEWSIZEH 100
Page custom page0 ; Write By 永恒心锁
Page Custom page1 ; GDI resize
Page Custom page2 ; Simple control resize
OutFile "OleLoadPicturePath.exe"
Function page0
nsDialogs::Create 1018
Pop $0
#第一个参数远程图片地址 w:WCHAR text, Unicode string
#第五个参数为全局唯一标识符,Globally Unique Identifier(GUID)
#最后一个参数指向图片界面
System::Call 'oleaut32::OleLoadPicturePath(w "${IMAGEPATH}", i 0, i 0, i 0, g "${IID_IPicture}", *i .r0)i.r1'
; $0 = pointer to image interface
; $1 = result code
System::Call '$0->3(*i.r2)i.r1' ; IPicture->get_Handle (VTable entry 3)
${NSD_CreateBitmap} 0 0 0 0 ""
Pop $9
;Not required when the control size matches: ${NSD_AddStyle} $9 ${SS_CENTERIMAGE}
SendMessage $9 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2
nsDialogs::Show
FunctionEnd
/*
STDAPI OleLoadPicturePath{
LPOLESTR szURLorPath,
LPUNKNOWN punkCaller,
DWORD dwReserved,
OLE_COLOR clrReserved,
REFIID riid,
LPVOID *ppvRet
}
*/
Function page1
nsDialogs::Create 1018
Pop $0
System::Call 'oleaut32::OleLoadPicturePath(w "${IMAGEPATH}",i0r2,i0,i0,g"${IID_IPicture}",*i.r9)i.r1'
#当图片被成功创建的时候,返回S_OK
${If} $1 = ${S_OK}
 System::Call 'user32::GetDC(i0)i.s'
 System::Call 'gdi32::CreateCompatibleDC(iss)i.r1'
 System::Call 'gdi32::CreateCompatibleBitmap(iss,i${NEWSIZEW},i${NEWSIZEH})i.r2'
 System::Call 'user32::ReleaseDC(i0,is)'
 System::Call $9->3(*i.r3)i.r4 ; IPicture->get_Handle
 ${If} $4 = 0
 System::Call 'gdi32::SetStretchBltMode(ir1,i4)'
 System::Call '*(&i40,&i1024)i.r4' ; BITMAP / BITMAPINFO
 System::Call 'gdi32::GetObject(ir3,i24,ir4)'
 System::Call 'gdi32::SelectObject(ir1,ir2)i.s'
 System::Call '*$4(i40,i.r6,i.r7,i0,i,i.s)' ; Grab size and bits-ptr AND init as BITMAPINFOHEADER
 System::Call 'gdi32::GetDIBits(ir1,ir3,i0,i0,i0,ir4,i0)' ; init BITMAPINFOHEADER
 System::Call 'gdi32::GetDIBits(ir1,ir3,i0,i0,i0,ir4,i0)' ; init BITMAPINFO
 System::Call 'gdi32::StretchDIBits(ir1,i0,i0,i${NEWSIZEW},i${NEWSIZEH},i0,i0,ir6,ir7,is,ir4,i0,i${SRCCOPY})'
 System::Call 'gdi32::SelectObject(ir1,is)'
 System::Free $4
 ${EndIf}
 System::Call 'gdi32::DeleteDC(ir1)'
 System::Call $9->2() ; IPicture->release()
${EndIf}
${NSD_CreateBitmap} 1u 1u ${NEWSIZEW} ${NEWSIZEH} ""
Pop $9
;Not required when the control size matches: ${NSD_AddStyle} $9 ${SS_CENTERIMAGE}
SendMessage $9 ${STM_SETIMAGE} ${IMAGE_BITMAP} $2
nsDialogs::Show
System::Call 'gdi32::DeleteObject(ir2)'
FunctionEnd
Function page2
nsDialogs::Create 1018
Pop $2
${NSD_CreateBitmap} 0 1u 70% 50% ""
Pop $3
${NSD_AddStyle} $3 ${SS_REALSIZECONTROL}
File "/oname=$PLUGINSDIRimage.bmp" "${NSISDIR}ContribGraphicsHeaderwin.bmp"
${NSD_SetImage} $3 "$PLUGINSDIRimage.bmp" $1
nsDialogs::Show
${NSD_FreeImage} $1
FunctionEnd
Section "永恒心锁"
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » OleLoadPicturePath在NSIS中如何改变远程图片的显示大小

您必须 登录 才能发表评论!