Jump to content

Recommended Posts

Is it possible to change the size of images in GDI+ ?

$hImage = _GDIPlus_ImageLoadFromFile($sPath)

This is the function that i use...

if i do this:

_GDIPlus_GraphicsDrawImage($aWindow[2], $hImage, $posX, $posY)

The picture comes to my screen but i see there no possibility to resize / scale the picture!

(I don't want to resize and save the picture with GDI+, i want to draw it bigger on my screen)

Link to post
Share on other sites

Try this:

#include <gdiplus.au3>


Global $fScaleW = 2.5
Global $fScaleH = 2.5
Global $sFile = StringReplace(@AutoItExe, "autoit3.exe", "ExamplesGUITorus.png")

Global $hBmp = ScaleImage($sFile, $fScaleW, $fScaleH)

Global $iW = _GDIPlus_ImageGetWidth($hBmp)
Global $iH = _GDIPlus_ImageGetHeight($hBmp)

Global $hGUI = GUICreate("GDI+ Image scaled to 250 %", $iW, $iH)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBmp, 0, 0)

Until GUIGetMsg() = - 3


Func ScaleImage($sFile, $iScaleW, $iScaleH, $iInterpolationMode = 7) ;coded by UEZ 2012
    If Not FileExists($sFile) Then Return SetError(1, 0, 0)
    Local $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    If @error Then Return SetError(2, 0, 0)
    Local $iWidth = _GDIPlus_ImageGetWidth($hImage) * $iScaleW
    Local $iHeight = _GDIPlus_ImageGetHeight($hImage) * $iScaleH
    Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0)
    If @error Then Return SetError(3, 0, 0)
    $hBitmap = $hBitmap[6]
    Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode)
    _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iWidth, $iHeight)
    Return $hBitmap



Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...