Werty 175 Posted December 19, 2010 (edited) I'm trying to show some pics on the gui using GDIPlus, but they dont show up in full size, they are shrunk. Example... #include <GDIPlus.au3> #include <GuiConstantsEx.au3> $gui = GUICreate("Virginia", 966, 1024) GUISetState() _GDIPlus_Startup() $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia.jpg") $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImage($hgraphic, $virginia, 0, 0) _GDIPlus_Shutdown() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE If I change the DPI of the pics they become bigger (or smaller), but how do I make it just show the pic, ignoring the DPI, showing in pixel size instead, pic being 500 pixels wide should be 500 pixels wide on screen aswell Thanks /edit Got it working this way... _GDIPlus_GraphicsDrawImageRect($hgraphic, $virginia, 0, 0, 500, 242) ..but please tell if there's a better way to do it. Edited December 19, 2010 by Werty Some guy's script + some other guy's script = my script! Share this post Link to post Share on other sites
UEZ 1,298 Posted December 19, 2010 Maybe this way: #include <GDIPlus.au3> #include <GuiConstantsEx.au3> _GDIPlus_Startup() $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia.jpg") $iW = _GDIPlus_ImageGetWidth($virginia) $iH = _GDIPlus_ImageGetHeight($virginia) $gui = GUICreate("Virginia", $iW, $iH) GUISetState() $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImageRect($hgraphic, $virginia, 0, 0, $iW, $iH) _GDIPlus_BitmapDispose($virginia) _GDIPlus_Shutdown() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit You can have a look here, too: Br, 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
Authenticity 14 Posted December 19, 2010 expandcollapse popup#include <GDIPlus.au3> #include <GuiConstantsEx.au3> Local $hGUI = GUICreate("Virginia", @DesktopWidth, @DesktopHeight) GUISetState() _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Local $hBitmap = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia.jpg") _GDIPlus_BitmapSetResolution($hBitmap, 96, 96) _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\virginia96DPI.jpg") Local $iTop _GDIPlus_BitmapSetResolution($hBitmap, 300, 300) $iTop = _GDIPlus_ImageGetHeight($hBitmap) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 0) _GDIPlus_BitmapSetResolution($hBitmap, 96, 96) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, $iTop) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() Func _GDIPlus_BitmapSetResolution($hBitmap, $nDpiX, $nDpiY) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapSetResolution", "ptr", $hBitmap, "float", $nDpiX, "float", $nDpiY) If @error Then Return SetError(@error, @extended, False) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc Changing the resolution does not change the physical size of the image. Share this post Link to post Share on other sites
Werty 175 Posted December 20, 2010 Maybe this way: #include <GDIPlus.au3> #include <GuiConstantsEx.au3> _GDIPlus_Startup() $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia.jpg") $iW = _GDIPlus_ImageGetWidth($virginia) $iH = _GDIPlus_ImageGetHeight($virginia) $gui = GUICreate("Virginia", $iW, $iH) GUISetState() $hgraphic = _GDIPlus_GraphicsCreateFromHWND($gui) _GDIPlus_GraphicsDrawImageRect($hgraphic, $virginia, 0, 0, $iW, $iH) _GDIPlus_BitmapDispose($virginia) _GDIPlus_Shutdown() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Exit You can have a look here, too: Br, UEZ Thanks, since you use ImageRect also, I guess that is right then. A question about Dispose(), how important is it, do I need to use it every time to avoid memleaks, or can I use the same variable and just fill it with something else, and then that will take over the mem used ? like.. $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia.jpg") ;do stuff with it here $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia2.jpg") ;do stuff with that also Etc etc ..or do I have to use Dispose() in between ? like so... $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia.jpg") ;do stuff with it here Bitmap_Dispose($virginia) $virginia = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\virginia2.jpg") ;do stuff with that also Bitmap_Dispose($virginia) Etc etc ? Some guy's script + some other guy's script = my script! Share this post Link to post Share on other sites