youtuber Posted December 21, 2017 Posted December 21, 2017 (edited) $hImage = _GDIPlus_ImageLoadFromFile($aImageSave) $X1 = _GDIPlus_ImageGetWidth($hImage) $Y1 = _GDIPlus_ImageGetHeight($hImage) $X2 = _GDIPlus_ImageGetWidth($hImage) $Y2 = _GDIPlus_ImageGetHeight($hImage) $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) ;$PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) _GDIPlus_GraphicsDrawImage ($hGraphic, 24, 152, 572, 268);? I have the same size and relative coords to $PicPreview in the image placement form1 I want to be Other Responsibility Is there a problem with _GDIPlus code sorting? expandcollapse popup#include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic, $OpenPictures, $PicPreview _GDIPlus_StartUp() $Form1 = GUICreate("Form1", 615, 438, 374, 347) $PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) $InputImageDir = GUICtrlCreateInput("", 64, 48, 177, 21) $ButtonOpen = GUICtrlCreateButton("...", 256, 48, 75, 25) $ButtonWatermark = GUICtrlCreateButton("Watermark Add", 256, 112, 80, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Exit Case $ButtonOpen $OpenPictures = FileOpenDialog("Where are the pictures?", @ScriptDir & "\", "Picture format (*.jpg;*.bmp;*.png)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If Not $OpenPictures Then MsgBox(64, "İnfo","No Files Selected!",5) Else GUICtrlSetData($InputImageDir,$OpenPictures) EndIf Case $ButtonWatermark $aImageLoad = $OpenPictures $aImageSave = @ScriptDir & "\Save.png" $aImageLogo = @ScriptDir & "\Logo.png" _Watermark($aImageSave, $aImageLoad, $aImageLogo) Case $ButtonPreview $hImage = _GDIPlus_ImageLoadFromFile($aImageSave) $X1 = _GDIPlus_ImageGetWidth($hImage) $Y1 = _GDIPlus_ImageGetHeight($hImage) $X2 = _GDIPlus_ImageGetWidth($hImage) $Y2 = _GDIPlus_ImageGetHeight($hImage) $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) ;$PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) _GDIPlus_GraphicsDrawImage ($hGraphic, 24, 152, 572, 268) EndSwitch WEnd Func _Watermark($sFile2, $sFile, $sLogo) Local $hImage1, $hImage2, $hGraphic _GDIPlus_Startup () $hImage1 = _GDIPlus_ImageLoadFromFile ($sFile) ; image $X1 = _GDIPlus_ImageGetWidth ($hImage1) $Y1 = _GDIPlus_ImageGetHeight ($hImage1) $hImage2 = _GDIPlus_ImageLoadFromFile ($sLogo) ; logo $X2 = _GDIPlus_ImageGetWidth ($hImage2) $Y2 = _GDIPlus_ImageGetHeight ($hImage2) $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) _GDIPlus_GraphicsDrawImage ($hGraphic, $hImage2, 20, $Y1-$Y2-30) _GDIPlus_ImageSaveToFile ($hImage1, $sFile2) ; image watermarked _GDIPlus_ImageDispose ($hImage1) _GDIPlus_ImageDispose ($hImage2) _GDIPlus_ShutDown () EndFunc ;==>_Watermark Edited December 21, 2017 by youtuber
c.haslam Posted December 22, 2017 Posted December 22, 2017 Post 17 of this thread may help re your first problem. I don't understand the second one. Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
UEZ Posted December 23, 2017 Posted December 23, 2017 @youtuber if you want to add an image as watermark then you can have a look to 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 24, 2017 Author Posted December 24, 2017 no no my goal is not watermark I would like that if the png format picture is the same as $PicPreview location $PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268)
UEZ Posted December 24, 2017 Posted December 24, 2017 You mean that you want to resize the image to the control size - here 572 x 268? If yes, then you can use _GDIPlus_ImageResize before you send the image to the control. Have in mind that the image must be in GDI format - _GDIPlus_ImageResize result is GDIPlus and thus you have to convert it to GDI first using _GDIPlus_BitmapCreateHBITMAPFromBitmap. youtuber 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 25, 2017 Author Posted December 25, 2017 (edited) @UEZ Thank you that is what I want But is there a missing code? Or is there a problem with the code sequence? #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $Form1 = GUICreate("Form1", 615, 438, 374, 347) ;$PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Exit Case $ButtonPreview $hImg = _GDIPlus_ImageResize($hImage, 572, 268) $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) _GDIPlus_GraphicsDrawImage ($hGraphic, $hImg, 24,152) EndSwitch WEnd Edited December 25, 2017 by youtuber
UEZ Posted December 26, 2017 Posted December 26, 2017 Something like this here? #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $Form1 = GUICreate("Form1", 615, 438, 374, 347) ;$PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) _GDIPlus_GraphicsSetInterpolationMode($hGraphic, 5) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Exit Case $ButtonPreview _GDIPlus_GraphicsDrawImageRect ($hGraphic, $hImage, 24,32, $iW * 2, $iH * 2) EndSwitch WEnd 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 26, 2017 Author Posted December 26, 2017 (edited) @UEZ I want to position it accordingly ;~ $PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) Edited December 26, 2017 by youtuber
UEZ Posted December 26, 2017 Posted December 26, 2017 expandcollapse popup#include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic, $iW, $iH, $iW_Prev, $iH_Prev, $PicPreview, $ButtonPreview, $iW_New, $iH_New, $iPrev_Min, $hBitmap_Prev, $hBitmapGDI_Prev _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $iW_Prev = 512 $iH_Prev = 368 $Form1 = GUICreate("Form1", 615, 438, 374, 347) $PicPreview = GUICtrlCreatePic("", 24, 32, $iW_Prev, $iH_Prev) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) $iW_New = $iW_Prev / $iW $iH_New = $iH_Prev / $iH $iPrev_Min = $iW_New < $iH_New ? $iH_New : $iH_New $hBitmap_Prev = _GDIPlus_ImageScale($hImage, $iPrev_Min, $iPrev_Min, 6) $hBitmapGDI_Prev = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Prev) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hBitmap_Prev) _WinAPI_DeleteObject($hBitmapGDI_Prev) _GDIPlus_ShutDown() Exit Case $ButtonPreview _WinAPI_DeleteObject(GUICtrlSendMsg($PicPreview, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmapGDI_Prev)) EndSwitch WEnd 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 26, 2017 Author Posted December 26, 2017 @UEZ I think you got me wrong I want to be in the same line $PicPreview , but not in the same line as you do Spoiler
UEZ Posted December 26, 2017 Posted December 26, 2017 (edited) And where is the problem to change the values for GUICtrlCreatePic? Have a look here to have an example how to adjust image in preview section properly. Edited December 26, 2017 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 26, 2017 Author Posted December 26, 2017 It does not work when I change the values like this $iW_Prev = 572 $iH_Prev = 268
UEZ Posted December 26, 2017 Posted December 26, 2017 Did you change it to $iW_Prev = 572 $iH_Prev = 268 $Form1 = GUICreate("Form1", 615, 438, 374, 347) $PicPreview = GUICtrlCreatePic("", 24, 152, $iW_Prev, $iH_Prev) ? 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 26, 2017 Author Posted December 26, 2017 Unfortunately the situation has not changed Spoiler
UEZ Posted December 26, 2017 Posted December 26, 2017 If you want the image stretched then try this: #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic, $iW, $iH, $iW_Prev, $iH_Prev, $PicPreview, $ButtonPreview, $iW_New, $iH_New, $iPrev_Min, $hBitmap_Prev, $hBitmapGDI_Prev _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $iW_Prev = 572 $iH_Prev = 268 $Form1 = GUICreate("Form1", 615, 438, 374, 347) $PicPreview = GUICtrlCreatePic("", 24, 152, $iW_Prev, $iH_Prev) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) $hBitmap_Prev = _GDIPlus_ImageResize($hImage, $iW_Prev, $iH_Prev, 6) $hBitmapGDI_Prev = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Prev) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hBitmap_Prev) _WinAPI_DeleteObject($hBitmapGDI_Prev) _GDIPlus_ShutDown() Exit Case $ButtonPreview _WinAPI_DeleteObject(GUICtrlSendMsg($PicPreview, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmapGDI_Prev)) EndSwitch WEnd youtuber 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
youtuber Posted December 26, 2017 Author Posted December 26, 2017 8 minutes ago, UEZ said: If you want the image stretched then try this: #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic, $iW, $iH, $iW_Prev, $iH_Prev, $PicPreview, $ButtonPreview, $iW_New, $iH_New, $iPrev_Min, $hBitmap_Prev, $hBitmapGDI_Prev _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $iW_Prev = 572 $iH_Prev = 268 $Form1 = GUICreate("Form1", 615, 438, 374, 347) $PicPreview = GUICtrlCreatePic("", 24, 152, $iW_Prev, $iH_Prev) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) $hBitmap_Prev = _GDIPlus_ImageResize($hImage, $iW_Prev, $iH_Prev, 6) $hBitmapGDI_Prev = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Prev) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hBitmap_Prev) _WinAPI_DeleteObject($hBitmapGDI_Prev) _GDIPlus_ShutDown() Exit Case $ButtonPreview _WinAPI_DeleteObject(GUICtrlSendMsg($PicPreview, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmapGDI_Prev)) EndSwitch WEnd Yes, that's what I want, but what's the difference? #include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $Form1, $hImage, $hGraphic _GDIPlus_StartUp() $hImage = _GDIPlus_BitmapCreateFromMemory(InetRead("https://www.autoitscript.com/images/favicon/favicon-180x180.png")) $Form1 = GUICreate("Form1", 615, 438, 374, 347) ;$PicPreview = GUICtrlCreatePic("", 24, 152, 572, 268) $ButtonPreview = GUICtrlCreateButton("Preview", 520, 112, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Exit Case $ButtonPreview $hImg = _GDIPlus_ImageResize($hImage, 572, 268) $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form1) _GDIPlus_GraphicsDrawImage ($hGraphic, $hImg, 24,152) EndSwitch WEnd
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