Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Placing transparent pic inside of another?

$
0
0

Greets All,

 

  I am attempting to create a transparent image icon file and then create that file inside of another image.  I already have code that can combine images together without any problems however I am having a bit of trouble creating the transparent image.  The error seems to throw at the "_WinAPI_Create32BitHICON" command...the following code is fairly well commented and I think explains how I'm trying to go about this...any helpful hints on the possible problem would be greatly appreciated.  I thank in advance.

AutoIt         
#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #Include <WinAPIEx.au3>  Global $hGUI  Global $MainGUI = GUICreate("Example", 425, 540, 450, 250)  GUISetState(@SW_SHOW)  _Combine() While 1    $nMsg = GUIGetMsg(1)  ;use advanced mode when using multiple GUIs    Switch $nMsg[1]  ;Switch on the GUI sending the message         Case $MainGUI             Switch $nMsg[0] ; switch on the control from the GUI sending the message.                 Case $GUI_EVENT_CLOSE                   Exit             EndSwitch     EndSwitch     Wend     Func _Combine()      $hGUI = GUICreate("Preview", 100, 100, 456, 563, $WS_BORDER, -1, $MainGUI)    GUISetBkColor(0xFFFFFF)  ;set GUI background to 'White'...  GUISetState(@SW_SHOW) ; Initialize GDI+ library _GDIPlus_Startup()  Local $hBitmap = _GDIPlus_BitmapCreateFromFile("C:\My Documents\_Green_Counter.png")    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)  ;the GUI acts as a graphics context in which to draw the image...  $hGraphics = _GDIPlus_ImageGetGraphicsContext($hBitmap)    ;the 'Counter' image itself acts as a graphics context in which to draw another image...  $hIcon = _WinAPI_Create32BitHICON("C:\My Documents\_Star.ico")      ;attempt to create/convert icon...not functioning (error returns "0")  _WinAPI_AddIconTransparency($hIcon, 25, 0)    ;attempt to make nearly transparent  _GDIPlus_GraphicsDrawImage($hGraphics, $hIcon, 20, 20)    ;draw the transparent icon in the original image...    _GDIPlus_ImageSaveToFile($hBitmap, "C:\My Documents\test.bmp")      ;save image  $hImage = _GDIPlus_ImageLoadFromFile("C:\My Documents\test.bmp")      ;load for display in window  _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 10, 10)      ;now can draw the 'Counter' (with its combined 'transparent icon') into the GUI as a 'preview sample'...     ; Clean up resources     _GDIPlus_GraphicsDispose($hGraphic)     _GDIPlus_GraphicsDispose($hGraphics)        _GDIPlus_ImageDispose($hBitmap)     _GDIPlus_ImageDispose($hImage)       _WinAPI_DestroyIcon($hIcon) ; Shut down GDI+ library _GDIPlus_Shutdown()  EndFunc

 

 

 

Attached Thumbnails

  • _Green_Counter.png

Attached Files


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>