Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog_loadImage
#11
Member function GdipImage.DrawResize
Code:
Copy      Help
function! hDc x y _width _height [quality] ;;quality: 0 default, 1 low, 2 high, 3 bilinear, 4 bicubic, 5 nearest neighbor, 6 high bilinear, 7 high bicubic

;Draws this image in the device context and resizes if need.
;Returns 1 on success, 0 if failed.

;If _height or _width is 0, calculates it to preserve aspect ratio. If both 0, uses original size.


if(!_width and !_height) ret Draw(hDc x y)

GdipGraphics g
if(!g.FromHDC(hDc)) ret

if(!_height) _height=MulDiv(this.height _width this.width)
if(!_width) _width=MulDiv(this.width _height this.height)

if(quality) GDIP.GdipSetInterpolationMode(g quality)

_hresult=GDIP.GdipDrawImageRectI(g m_i x y _width _height)
ret !_hresult

example
Function dialog_gdi_plus_resize_image
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

if(!ShowDialog("dialog_gdi_plus_resize_image" &dialog_gdi_plus_resize_image)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2030503 "*" "" "" ""

ret
;messages
#compile "__Gdip"
sel message
,case WM_INITDIALOG
,GdipImage-- t_im
,;if(!t_im.FromFile("q:\test\app_55.png")) ret
,if(!t_im.FromFile("$documents$\foto\__kate.jpg")) ret
,
,case WM_PAINT
,if(!t_im) ret
,
,PAINTSTRUCT ps
,BeginPaint hDlg &ps
,t_im.DrawResize(ps.hDC 0 0 100 0 7)
,EndPaint hDlg &ps
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1


Messages In This Thread

Forum Jump:


Users browsing this thread: 8 Guest(s)