Jump to content

SplashImage .png


Recommended Posts

You have many ways for do that. all of them uses the GDIPlus Library.

Here`s an example.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>
#include <gdiplus.au3>
local $Ipath = @Scriptdir&"\button.png"
local $transColor = 0xABCDEF
If not fileexists($Ipath) then Inetget("http://img26.imageshack.us/img26/7439/boton3p.png",$Ipath)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($Ipath)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$hGui = GUICreate("Test hover", $width, $height,-1,-1,$WS_POPUP,$WS_EX_LAYERED)
Guisetbkcolor($transColor,$hGui)
_WinAPI_SetLayeredWindowAttributes($hGui,$transColor,255)
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
_GDIPlus_GraphicsDrawImageRect($hGraphic,$hImage,0,0,$width,$height)
Do
Until GUIGetMsg() = -3
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()

If you want to use a PNG with semi transparencies is using the a function that is in several post in the forum. SetBitmap

The link of the original post is this:

And an example here:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <winapi.au3>
#include <gdiplus.au3>
local $Ipath = @Scriptdir&"\testGUI.png"
local $transColor = 0xABCDEF
If not fileexists($Ipath) then Inetget("http://img146.imageshack.us/img146/9861/testgui.png",$Ipath)
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($Ipath)
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)
$hGui = GUICreate("Test hover", $width, $height,-1,-1,$WS_POPUP, $WS_EX_LAYERED)
SetBitmap($hGui,$hImage,255)
Guisetstate()
Do
Until GUIGetMsg() = -3
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
    $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", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap

Do any question you want.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...