Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog_loadImage
#1
Function Dialog_loadImage
Code:
Copy      Help
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
Code:
Copy      Help
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.


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)