this-is-me Posted March 18, 2010 Posted March 18, 2010 (edited) EDIT: This problem is now solved using the script found here.I am trying to create a PNG gui from an original PNG of about 256 pixels in size and display it as ~50 pixels. I don't want to save a temporary image to disk before showing it.I have already looked among the forums and I am a novice at GDI. I understand how to display a PNG gui as the original size, but don't know how to resize the PNG before display and keep the alpha channel. I think I need to be using _GDIPlus_GraphicsDrawImageRect, which allows me to specify the size, but I don't understand what to draw to and how to do it. Right now, I don't care about the resized image quality, just about doing the resize in memory (I don't want to run an external program).Here is the script as-is.expandcollapse popup#include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> Global Const $AC_SRC_ALPHA = 1 _GDIPlus_Startup() $pngSrc = @ScriptDir & "\Windows.png" ;243x243 $GUI = _GUICreate_Alpha("Test", $pngSrc) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd _GDIPlus_Shutdown() Func _GUICreate_Alpha($sTitle, $sPath, $iX=-1, $iY=-1, $iOpacity=255) Local $hGUI, $hImage, $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hImage = _GDIPlus_ImageLoadFromFile($sPath) $width = _GDIPlus_ImageGetWidth($hImage) $height = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate($sTitle, $width, $height, $iX, $iY, $WS_POPUP, $WS_EX_LAYERED) $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $width) DllStructSetData($tSize, "Y", $height) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 2) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>_GUICreate_Alpha Edited March 18, 2010 by this-is-me Who else would I be?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now