04-04-2013, 09:22 PM
Function Dialog_loadImage
To avoid memory leaks use this function:
Function hWnd_LoadImageFromMemory
Requires Archive: http://www.quickmacros.com/forum/showthr...p?tid=2852 and other functions listed in this thread.
function ~sPath double'height double'width hDlg hId
;;hId is id of static dialog element
int hb=GdipLoadPictureFile(sPath)
GetImageSize(sPath int'w int'h)
if w>h
,height=(width/w)*h
if h>w
,width=(height/h)*w
hb=CopyImage(hb 0 width height 0)
SendMessage id(hId hDlg) STM_SETIMAGE IMAGE_BITMAP hb
__GdiHandle-- _hb=SendMessage(id(15 hDlg) STM_GETIMAGE IMAGE_BITMAP 0); if(_hb!=hb) DeleteObject(hb)
To avoid memory leaks use this function:
Function hWnd_LoadImageFromMemory
function ~imageFileData hWnd [double'height] [double'width]
;;hWnd is id of static dialog element
int hb=GdipLoadPictureFileFromMemory(imageFileData)
BITMAP bi
if(GetObjectW(hb sizeof(bi) &bi))
,int w=bi.bmWidth
,int h=bi.bmHeight
if (height and width)
,if w>h;height=(width/w)*h
,if h>w;width=(height/h)*w
else height=h;width=w
hb=CopyImage(hb 0 width height LR_COPYDELETEORG)
StaticImageControlSetBitmap hWnd hb
DeleteObject hb
DeleteObject LR_COPYDELETEORG
Requires Archive: http://www.quickmacros.com/forum/showthr...p?tid=2852 and other functions listed in this thread.