Jump to content
Sign in to follow this  
Pelix

GDI + stretches images automatically

Recommended Posts

Pelix

Hello community,

I have a problem with GDI + which I do not understand.

_GDIPlus_StartUp()

$hGUI = GUICreate($win_title, 600, 600, -1, -1, $WS_POPUP)
GUICtrlCreateLabel("", 0, 0, 600, 55, -1, $GUI_WS_EX_PARENTDRAG)
GUISetState()

$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\client.jpg")
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

_GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 0, 0)


; START WINDOW

While 1
   Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         ExitLoop
   EndSwitch
WEnd

; CLEANUP

_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_ShutDown()
GUIDelete($hGUI)

I have created the window with 600x600. Everything works but the image "client.jpg" is streched ... when i create the image with 450x450 then its complete inside of the 600x600 ... when i create the image with 600x600 then its 750x750 inside ... this doesnt look good. :/

Any idea? Why GDI+ stretch the image? :/

Share this post


Link to post
Share on other sites
Pelix

Ok i have found a solution

$hBitmap_Scaled = _GDIPlus_ImageResize($hImage, 600, 600)
_GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap_Scaled, 0, 0)

But why the image will be scaled up auto?

Share this post


Link to post
Share on other sites
UEZ

Might depending on the DPI of the image. Alternatively you can use _GDIPlus_GraphicsDrawImageRect.

 

  • Like 1

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×