Sign in to follow this  
Followers 0
monoscout999

GDI+ Back Buffering two BitBlt calls to avoid flickering

9 posts in this topic

#1 ·  Posted (edited)

Hi forum i want to make a GUI that cause a Blur effect in the Background found a method:

superimpose two images, one original and one slightly out of phase with the original.

the idea is to do this effect in real time.

I don´t know how to remove the flickering that the two calls of BitBlt produces.. help me to find out how to deal with it,

This is the code:

#include <WinAPIEx.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
 
HotKeySet("{Esc}", "_Exit")
 
$hForm = GUICreate('MyGUI', 200, 200, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
$Pic = GUICtrlCreatePic('', 0, 0, 200, 200, -1, $GUI_WS_EX_PARENTDRAG)
$hPic = GUICtrlGetHandle($Pic)
 
GUISetBkColor(0x123456)
_WinAPI_SetLayeredWindowAttributes($hForm, 0x123456, 255, 0x01)
 
GUISetState()
 
$hDC = _WinAPI_GetDC($hPic)
$hDeskDC = _WinAPI_GetDC(0)
 
_GDIPlus_Startup()
 
$hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)
_GDIPlus_GraphicsClear($hGraphics, 0xFF123456)
 
$hGBitmap = _GDIPlus_BitmapCreateFromGraphics(200, 200, $hGraphics)
$hGBackbuffer = _GDIPlus_ImageGetGraphicsContext($hGBitmap)
 
$hBrush = _GDIPlus_BrushCreateSolid(0xFF123456)
 
AdlibRegister("MyPaint", 100)
 
GUISetState()
 
Do
Until GUIGetMsg() = -3
 
_Exit()
 
Func MyPaint()
    $aPos = WinGetPos($hForm)
    _GDIPlus_GraphicsFillRect($hGBackbuffer, 0, 0, 200, 200, $hBrush)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hGBitmap, 0, 0)
    _WinAPI_BitBlt($hDC, 0, 0, 200, 200, $hDeskDC, $aPos[0], $aPos[1], $SRCCOPY)
    _WinAPI_BitBlt($hDC, 0, 0, 200, 200, $hDeskDC, $aPos[0] - 1, $aPos[1] - 1, $SRCAND) ; To make the Blur effect
EndFunc   ;==>MyPaint
 
Func _Exit()
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGBackbuffer)
    _GDIPlus_BitmapDispose($hGBitmap)
    _GDIPlus_Shutdown()
    _WinAPI_ReleaseDC($hPic, $hDC)
    _WinAPI_ReleaseDC(0, $hDeskDC)
    Exit
EndFunc   ;==>_Exit

One theory that i have is to use a different DestDC in the first BitBlt and pass it as SrcDC in the second call, but i don´t know how to do it.

I already have many versions of this work, and this is the most promising so far. but i am open to suggestions,

Edited by monoscout999

Share this post


Link to post
Share on other sites



Have a look at this code by Siao

it blurs the desktop, then you can use the gui as a squeegee to clean the screen

Blurring the screen


I see fascists...

Share this post


Link to post
Share on other sites

I want to do the opposite, just like AERO do... but someone just told me that AERO use Video Card instead Windows functions to do the blur, so my chances of matching almost the performance of AERO are few..

Share this post


Link to post
Share on other sites

Tried the above siao code.

Does anyone know where the missing constants now reside

$RDW_INVALIDATE
$RDW_UPDATENOW
$RDW_ALLCHILDREN
$RDW_INVALIDATE

i include WinAPIEx.au3 and it works , but where are those constants... who knows. :mellow:

Share this post


Link to post
Share on other sites

Try this:

#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
 
_GDIPlus_Startup()
$w = 640
$h = 480
$hGUI = GUICreate("Test", $w, $h)
$idPic = GUICtrlCreatePic("", 0, 0, $w, $h)
GUISetState()
 
$hHBITMAP = _ScreenCapture_Capture("", 0, 0, $w, $h)
$hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBITMAP)
_WinAPI_DeleteObject($hHBITMAP)
$hBitmap_Blur = _Blur($hBitmap, $w, $h, 0.2)
$hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_Blur)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_BitmapDispose($hBitmap_Blur)
_GDIPlus_Shutdown()
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, 0x0172, 0, $hHBITMAP))
 
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
Exit
 
Func _Blur($hBitmap, $iW, $iH, $fScale = 0.175, $qual = 6); by eukalyptus
Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
Local $hBmpSmall = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Local $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall)
DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGfxSmall, "int", 2)
Local $hBmpBig = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
Local $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig)
DllCall($ghGDIPDll, "uint", "GdipSetPixelOffsetMode", "hwnd", $hGfxBig, "int", 2)
DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGfxSmall, "float", $fScale, "float", $fScale, "int", 0)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfxSmall, "int", $qual)
DllCall($ghGDIPDll, "uint", "GdipScaleWorldTransform", "hwnd", $hGfxBig, "float", 1 / $fScale, "float",  1 / $fScale, "int", 0)
DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "hwnd", $hGfxBig, "int", $qual)
_GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap, 0, -5, $iW, $iH + 12)
_GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, -3, $iW, $iH + 9)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_BitmapDispose($hBmpSmall)
_GDIPlus_GraphicsDispose($hGfxSmall)
_GDIPlus_GraphicsDispose($hGfxBig)
Return $hBmpBig
EndFunc   ;==>_Blur

Or from GDIp.au3 examples:

#include <GDIplus.au3>
 
Global Const $GDIP_BLUREFFECT = "{633C80A4-1843-482b-9EF2-BE2834C5FDD4}"
Global Const $GDIP_SHARPENEFFECT = "{63CBF3EE-C526-402c-8F71-62C540BF5142}"
Global Const $GDIP_COLORMATRIXEFFECT = "{718F2615-7933-40e3-A511-5F68FE14DD74}"
Global Const $GDIP_COLORLUTEFFECT = "{A7CE72A9-0F7F-40d7-B3CC-D0C02D5C3212}"
Global Const $GDIP_BRIGHTNESSCONTRASTEFFECT = "{D3A1DBE1-8EC4-4c17-9F4C-EA97AD1C343D}"
Global Const $GDIP_HUESATURATIONLIGHTNESSEFFECT = "{8B2DD6C3-EB07-4d87-A5F0-7108E26A9C5F}"
Global Const $GDIP_LEVELSEFFECT = "{99C354EC-2A31-4f3a-8C34-17A803B33A25}"
Global Const $GDIP_TINTEFFECT = "{1077AF00-2848-4441-9489-44AD4C2D7A2C}"
Global Const $GDIP_COLORBALANCEEFFECT = "{537E597D-251E-48da-9664-29CA496B70F8}"
Global Const $GDIP_REDEYECORRECTIONEFFECT = "{74D29D05-69A4-4266-9549-3CC52836B632}"
Global Const $GDIP_COLORCURVEEFFECT = "{DD6A0022-58E4-4a67-9D9B-D48EB881A53D}"
 
_GDIPlus11_Startup()
If @error Then Exit MsgBox(0x10, "Error", "GDIPlus v1.1 is not installed")
 
;~ _GDIPlus_Startup()
 
Local $hGUI, $hGraphics, $hImage, $hBlurredImage,  $hEffect, $file
$file = FileOpenDialog("Select Image", "", "Images (*.jpg;*.png;*.bmp;*.gif)")
If @error Then Exit
$hImage = _GDIPlus_ImageLoadFromFile($file)
 
$hGUI = GUICreate("GDI+ v1.1 Demo Blur", _GDIPlus_ImageGetWidth($hImage), _GDIPlus_ImageGetHeight($hImage))
GUISetState()
$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hEffect = _GDIPlus_EffectCreate($GDIP_BLUREFFECT)
$hBlurredImage = _GDIPlus_BitmapCreateWithEffect($hImage, $hEffect)
 
_GDIPlus_GraphicsDrawImage($hGraphics, $hBlurredImage, 0, 0)
 
Do
Until GUIGetMsg() = -3
 
_GDIPlus_BitmapDispose($hBlurredImage)
_GDIPlus_EffectDispose($hEffect)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hGraphics)
 
_GDIPlus11_Shutdown()
;~ _GDIPlus_Shutdown()
 
Func _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect, $pROI = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapApplyEffect", "hwnd", $hBitmap, "hwnd", $hEffect, "ptr", $pROI, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc
 
Func _GDIPlus_BitmapCreateWithEffect($hBitmap, $hEffect, $pROI = 0, $pOutRect = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapCreateApplyEffect", "ptr*", $hBitmap, "int", 1, "hwnd", $hEffect, "ptr", $pROI, "ptr", $pOutRect, "int*", 0, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[6])
EndFunc
 
Func _GDIPlus_EffectCreate($sEffectGUID)
    Local $iI, $tGUID, $pGUID, $tElem, $aElem[4], $aResult
 
    $tGUID = _WinAPI_GUIDFromString($sEffectGUID)
    $pGUID = DllStructGetPtr($tGUID)
 
    $tElem = DllStructCreate("int[4]", $pGUID)
    For $iI = 1 To 4
        $aElem[$iI-1] = DllStructGetData($tElem, 1, $iI)
    Next
 
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateEffect", "int", $aElem[0], "int", $aElem[1], "int", $aElem[2], "int", $aElem[3], "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[5])
EndFunc
 
Func _GDIPlus_EffectDispose($hEffect)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteEffect", "hwnd", $hEffect)
 
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc
 
Func _GDIPlus11_Startup()
    Local $pInput, $tInput, $pToken, $tToken, $aResult, $os
 
    $giGDIPRef += 1
    If $giGDIPRef > 1 Then Return True
 
    If @OSVersion = "WIN_VISTA" Then
$ghGDIPDll = DllOpen(@WindowsDir & "\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.6000.16386_none_8df21b8362744ace\gdiplus.dll")
ElseIf @OSVersion = "WIN_7" Then
$ghGDIPDll = DllOpen(@SystemDir & "\gdiplus.dll")
Else
Return SetError(1)
EndIf
;~     _WinAPI_Check("_GDIPlus_Startup (GDIPlus.dll not found)", @error, False)
 
    $tInput = DllStructCreate($tagGDIPSTARTUPINPUT)
    $pInput = DllStructGetPtr($tInput)
    $tToken = DllStructCreate("int Data")
    $pToken = DllStructGetPtr($tToken)
    DllStructSetData($tInput, "Version", 1)
    $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0)
    If @error Then Return SetError(@error, @extended, False)
    $giGDIPToken = DllStructGetData($tToken, "Data")
    Return $aResult[0] = 0
EndFunc
 
Func _GDIPlus11_Shutdown()
    If $ghGDIPDll = 0 Then Return SetError(-1, -1, False)
 
    $giGDIPRef -= 1
    If $giGDIPRef = 0 Then
        DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", $giGDIPToken)
        DllClose($ghGDIPDll)
        $ghGDIPDll = 0
    EndIf
    Return True
EndFunc

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
:mellow: Thank you UEZ i think that i can do something with the second example. :) i never knew how to use the GDI+ effect class.

Share this post


Link to post
Share on other sites

This is far away of being prolix but you will get an idea...

#AutoIt3Wrapper_UseX64=n
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#include <GDIPlus.au3>

Global Const $GDIP_BLUREFFECT = "{633C80A4-1843-482b-9EF2-BE2834C5FDD4}"
Global Const $GDIP_SHARPENEFFECT = "{63CBF3EE-C526-402c-8F71-62C540BF5142}"
Global Const $GDIP_COLORMATRIXEFFECT = "{718F2615-7933-40e3-A511-5F68FE14DD74}"
Global Const $GDIP_COLORLUTEFFECT = "{A7CE72A9-0F7F-40d7-B3CC-D0C02D5C3212}"
Global Const $GDIP_BRIGHTNESSCONTRASTEFFECT = "{D3A1DBE1-8EC4-4c17-9F4C-EA97AD1C343D}"
Global Const $GDIP_HUESATURATIONLIGHTNESSEFFECT = "{8B2DD6C3-EB07-4d87-A5F0-7108E26A9C5F}"
Global Const $GDIP_LEVELSEFFECT = "{99C354EC-2A31-4f3a-8C34-17A803B33A25}"
Global Const $GDIP_TINTEFFECT = "{1077AF00-2848-4441-9489-44AD4C2D7A2C}"
Global Const $GDIP_COLORBALANCEEFFECT = "{537E597D-251E-48da-9664-29CA496B70F8}"
Global Const $GDIP_REDEYECORRECTIONEFFECT = "{74D29D05-69A4-4266-9549-3CC52836B632}"
Global Const $GDIP_COLORCURVEEFFECT = "{DD6A0022-58E4-4a67-9D9B-D48EB881A53D}"

HotKeySet("{ESC}", "_Exit")

Global $hDCBuffer, $Timer, $Results

$hGui = GUICreate("Test Blur", -1, -1, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0x227722)
_WinAPI_SetLayeredWindowAttributes($hGui, 0x227722, 220, 0x02)
$iButton = GUICtrlCreateButton("Test", 10, 10, 150, 40)
GUISetState()

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_MOVING, "WM_MOVING")

$hDeskDC = _WinAPI_GetDC(0)
$hDC = _WinAPI_GetDC($hGui)

_GDIPlus11_Startup()

$hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC)

$hRgn = _WinAPI_CreateRectRgn(10, 10, 160, 50)
_GDIPlus_GraphicsSetClipHrgn($hGraphics, $hRgn, 3)

$hBitmapBuffer = _GDIPlus_BitmapCreateFromGraphics(400, 400, $hGraphics)
$hGraphBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmapBuffer)

$hBrush = _GDIPlus_BrushCreateSolid(0x33550055)

$tRECT = DllStructCreate($tagRECT)

$hEffect = _GDIPlus_EffectCreate($GDIP_BLUREFFECT)

AdlibRegister("AllTimeDrawing", 50)

$WinPos = WinGetPos($hGui) ; Only Once

While True
    $iMsg = GUIGetMsg()
    If $iMsg = -3 Then ExitLoop
    If $iMsg = $iButton Then ConsoleWrite($Results & @CRLF)
WEnd

_Exit()

Func WM_NCHITTEST($hWndGUI, $MsgID, $WParam, $LParam)
    If ($hWndGUI = $hGui) And ($MsgID = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

Func WM_MOVING($hWndGUI, $MsgID, $WParam, $LParam)
    $Timer = TimerInit()
    AdlibUnRegister("AllTimeDrawing")
    _GDIPlus_GraphicsReleaseDC($hGraphBuffer, $hDCBuffer)
    $tRECT = DllStructCreate($tagRECT, $LParam)
    $WinPos[0] = DllStructGetData($tRECT, 1)
    $WinPos[1] = DllStructGetData($tRECT, 2)
    $WinPos[2] = DllStructGetData($tRECT, 3) - $WinPos[0]
    $WinPos[3] = DllStructGetData($tRECT, 4) - $WinPos[1]
    $hDCBuffer = _GDIPlus_GraphicsGetDC($hGraphBuffer)
    _WinAPI_BitBlt($hDCBuffer, 0, 0, 400, 400, $hDeskDC, $WinPos[0], $WinPos[1], $SRCCOPY)
    _GDIPlus_GraphicsReleaseDC($hGraphBuffer, $hDCBuffer)
    _GDIPlus_GraphicsFillRect($hGraphBuffer, 0, 0, 400, 400, $hBrush)
    $hBlurredImage = _GDIPlus_BitmapCreateWithEffect($hBitmapBuffer, $hEffect)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBlurredImage, 0, 0, 400, 400)
    _GDIPlus_BitmapDispose($hBlurredImage)

    AdlibRegister("AllTimeDrawing", 50)
    $Results = TimerDiff($Timer)
    Return True
EndFunc   ;==>WM_MOVING

Func AllTimeDrawing()
;~    $Timer = TimerInit()
    $hDCBuffer = _GDIPlus_GraphicsGetDC($hGraphBuffer)
    _WinAPI_BitBlt($hDCBuffer, 0, 0, 400, 400, $hDeskDC, $WinPos[0], $WinPos[1], $SRCCOPY)
    _GDIPlus_GraphicsReleaseDC($hGraphBuffer, $hDCBuffer)
    _GDIPlus_GraphicsFillRect($hGraphBuffer, 0, 0, 400, 400, $hBrush)
    $hBlurredImage = _GDIPlus_BitmapCreateWithEffect($hBitmapBuffer, $hEffect)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBlurredImage, 0, 0, 400, 400)
    _GDIPlus_BitmapDispose($hBlurredImage)
;~    $Results = TimerDiff($Timer)
EndFunc   ;==>AllTimeDrawing

Func _GDIPlus_GraphicsSetClipHrgn($hGraphics, $hRgn, $iCombineMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetClipHrgn", "hwnd", $hGraphics, "hwnd", $hRgn, "int", $iCombineMode)

    If @error Then Return SetError(@error, @extended, False)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_GraphicsSetClipHrgn

Func _Exit()
    AdlibUnRegister("AllTimeDrawing")
    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphBuffer)
    _GDIPlus_BitmapDispose($hBitmapBuffer)
    _WinAPI_DeleteObject($hRgn)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus11_Shutdown()
    _WinAPI_ReleaseDC($hGui, $hDC)
    _WinAPI_ReleaseDC(0, $hDeskDC)
    Exit
EndFunc   ;==>_Exit
Func _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect, $pROI = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapApplyEffect", "hwnd", $hBitmap, "hwnd", $hEffect, "ptr", $pROI, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc

Func _GDIPlus_BitmapCreateWithEffect($hBitmap, $hEffect, $pROI = 0, $pOutRect = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapCreateApplyEffect", "ptr*", $hBitmap, "int", 1, "hwnd", $hEffect, "ptr", $pROI, "ptr", $pOutRect, "int*", 0, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[6])
EndFunc

Func _GDIPlus_EffectCreate($sEffectGUID)
    Local $iI, $tGUID, $pGUID, $tElem, $aElem[4], $aResult

    $tGUID = _WinAPI_GUIDFromString($sEffectGUID)
    $pGUID = DllStructGetPtr($tGUID)

    $tElem = DllStructCreate("int[4]", $pGUID)
    For $iI = 1 To 4
        $aElem[$iI-1] = DllStructGetData($tElem, 1, $iI)
    Next

    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateEffect", "int", $aElem[0], "int", $aElem[1], "int", $aElem[2], "int", $aElem[3], "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[5])
EndFunc

Func _GDIPlus_EffectDispose($hEffect)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteEffect", "hwnd", $hEffect)

    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc

Func _GDIPlus11_Startup()
    Local $pInput, $tInput, $pToken, $tToken, $aResult, $os

    $giGDIPRef += 1
    If $giGDIPRef > 1 Then Return True

    If @OSVersion = "WIN_VISTA" Then
$ghGDIPDll = DllOpen(@WindowsDir & "\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.6000.16386_none_8df21b8362744ace\gdiplus.dll")
ElseIf @OSVersion = "WIN_7" Then
$ghGDIPDll = DllOpen(@SystemDir & "\gdiplus.dll")
Else
Return SetError(1)
EndIf
;~   _WinAPI_Check("_GDIPlus_Startup (GDIPlus.dll not found)", @error, False)

    $tInput = DllStructCreate($tagGDIPSTARTUPINPUT)
    $pInput = DllStructGetPtr($tInput)
    $tToken = DllStructCreate("int Data")
    $pToken = DllStructGetPtr($tToken)
    DllStructSetData($tInput, "Version", 1)
    $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0)
    If @error Then Return SetError(@error, @extended, False)
    $giGDIPToken = DllStructGetData($tToken, "Data")
    Return $aResult[0] = 0
EndFunc

Func _GDIPlus11_Shutdown()
    If $ghGDIPDll = 0 Then Return SetError(-1, -1, False)

    $giGDIPRef -= 1
    If $giGDIPRef = 0 Then
        DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", $giGDIPToken)
        DllClose($ghGDIPDll)
        $ghGDIPDll = 0
    EndIf
    Return True
EndFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0