[GDI+] Verwischen / Unscharf machen

  • Tag zusammen.

    Ich wollte per

    [autoit]

    _ScreenCapture_Capture

    [/autoit]


    den Bildschirm aufnehmen und in einer GUI als Vollbild darstellen.

    Leider sieht das komisch aus, und da ich Text in dieses Bild projezieren wollte,
    würde ich gerne das Bild verwischen, so dass es am Ende wie z.bsp. bei "Portal" im Pausenmenü aussieht...

    mfg,
    dankeschön

    Zitat

    Programmieren ist so lange lustig bis ein Fehler auftritt!


    ~ Dankeschön

    Einmal editiert, zuletzt von Dankeschön (21. November 2010 um 23:25)

  • Du meinst so eine Art Gaußschen Weichzeichner? Das gibt es soweit ich weiß nicht in der GDIPlus.dll...
    Ich glaube jemand hat mal so eine Funktion gebastelt, die war aber unglaublich langsam (Es bringt ja nichts wenn das Bild 20 Sekunden zum Berechnen braucht). ^^
    Vielleicht kann man auch was mit der GDIP.au3 basteln, aber ob das dann schnell gennug ist.

  • GdipCreateEffect(const GUID guid, CGpEffect **effect), MSDN ist dein Freund^^
    GGf hat Yashied diese Funktion schon gewrappert oder sie ist in einer der GDI-UDF´s bereits enthalten

    "Verwischen" ist z.B. BLUR

  • Hier ein Beispiel von Authenticity (dem GDIp.au3 Ersteller):

    Spoiler anzeigen
    [autoit]


    #include <GDIplus.au3>

    [/autoit] [autoit][/autoit] [autoit]

    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}"

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus11_Startup()
    If @error Then Exit MsgBox(0x10, "Error", "GDIPlus v1.1 is not installed")

    [/autoit] [autoit][/autoit] [autoit]

    ;~ _GDIPlus_Startup()

    [/autoit] [autoit][/autoit] [autoit]

    Local $hGUI, $hGraphics, $hImage, $hBlurredImage, $hEffect, $file
    $file = FileOpenDialog("Select Image", "", "Images (*.jpg;*.png;*.bmp;*.gif)")
    If @error Then Exit
    $hImage = _GDIPlus_ImageLoadFromFile($file)

    [/autoit] [autoit][/autoit] [autoit]

    $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)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBlurredImage, 0, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = -3

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_BitmapDispose($hBlurredImage)
    _GDIPlus_EffectDispose($hEffect)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_GraphicsDispose($hGraphics)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus11_Shutdown()
    ;~ _GDIPlus_Shutdown()

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    $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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    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)

    [/autoit] [autoit][/autoit] [autoit]

    $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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit]

    Solle ab Vista+ laufen!

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Hallo!

    bei mir kam das Script zum Abstürzen...Win7 x64
    dann hab ich beim Autoit Wrapper die 64bit-Funktion deaktiviert, jetzt gehts.... -.-
    falls es jemandem weiterhilft.... ;)
    Grüße,
    r4lf

  • Hier eine alternativ Funktion von Eukalyptus:

    [autoit]


    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)

    [/autoit][autoit][/autoit][autoit]

    Local $hBmpBig = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    Local $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsScaleTransform($hGfxSmall, $fScale, $fScale)
    _GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, $qual)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fScale, 1 / $fScale)
    _GDIPlus_GraphicsSetInterpolationMode($hGfxBig, $qual)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDrawImageRect($hGfxSmall, $hBitmap, 0, -5, $iW, $iH + 12)
    _GDIPlus_GraphicsDrawImageRect($hGfxBig, $hBmpSmall, 0, -3, $iW, $iH + 9)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_BitmapDispose($hBmpSmall)
    _GDIPlus_GraphicsDispose($hGfxSmall)
    _GDIPlus_GraphicsDispose($hGfxBig)
    Return $hBmpBig
    EndFunc ;==>_Blur

    [/autoit]

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯