GDI+: Weichzeichnen u. Verdunkeln möglich?

  • Hey,


    ist es möglich eine Bitmap weichzuzeichen/unscharf zu machen und/oder zu verdunkeln (das glaube ich müsste anhand der Farbwerte gehen, weiß nur leider nich wie)?


    Gruß Andy :)

    3 Mal editiert, zuletzt von AndyTR (29. September 2010 um 19:09)

  • Erstmal dank Dir UEZ, da sind tolle Beispiele dabei...

    Also Verdunkeln,Sättigen usw. is möglich, aber hab die GDIP.au3 mal nach "blur" durchsucht; da findet sich leider nichts...

    Zu schade, weil das das wichtigste ist. Dann werd ich wohl oder übel darauf verzichten müssen, wenns keine Lösung gibt :(


    Dennoch danke für die fixe Antwort, und vllt gibts ja doch noch ne Möglichkeit, die hier jemand weiß :)

  • Oh oh ich hab doch noch Probleme 8|


    Mir scheint, dies hier ist ein Beispiel zum Weichzeichnen...

    Dort wird aber nicht "die normale" GDIPlus.dll geladen, sondern Version 1.1 (sieht man auch am Pfad im Win-Ordner)...

    Und dann hab ich das hier gefunden (der post vom 28. Nov.); und im ersten link schreibt Authenticity das ja auch...


    Heißt das, dass das garnicht klappen kann, wenn ich XP benutze? :P


    Andy :)

  • Weichzeichnen könntest du evtl auch so erreichen.

    Probier mal etwas mit diesen Funktionen rum:
    _GDIPlus_GraphicsScaleTransform
    _GDIPlus_GraphicsSetInterpolationMode
    _GdiPlus_GraphicsSetSmoothingMode

    euf ein temporäres Bitmap kleiner zeichnen und von dort wieder vergrößert auf das eigentliche Ziel zeichnen

    hab ich nicht ausprobiert und verspreche keinen Erfolg ;)

    mfgE

  • zum Beispiel so:

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include "GDIP.au3"
    #include <GUIConstantsEx.au3>
    #include <WinAPI.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $sFile = FileOpenDialog("Öffnen", "", "(*.jpg;*.bmp;*.png;*.tif)")

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

    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($sFile)
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)

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

    $hGui = GUICreate("Test", $iWidth, $iHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_EXIT")
    GUISetState()

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

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hBitmap = _Blur($hImage, 0.2)

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

    $bBlur = True
    While 1
    Switch $bBlur
    Case True
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)
    $bBlur = False
    Case Else
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
    $bBlur = True
    EndSwitch

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

    Sleep(500)
    WEnd

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

    Func _Blur($hBitmap, $fScale = 0.2)
    Local $iW = _GDIPlus_ImageGetWidth($hBitmap)
    Local $iH = _GDIPlus_ImageGetHeight($hBitmap)
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND(_WinAPI_GetDesktopWindow())
    Local $hBmpSmall = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    Local $hGfxSmall = _GDIPlus_ImageGetGraphicsContext($hBmpSmall)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxSmall, 2)
    Local $hBmpBig = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
    Local $hGfxBig = _GDIPlus_ImageGetGraphicsContext($hBmpBig)
    _GDIPlus_GraphicsSetSmoothingMode($hGfxBig, 2)
    _GDIPlus_GraphicsScaleTransform($hGfxSmall, $fScale, $fScale)
    _GDIPlus_GraphicsSetInterpolationMode($hGfxSmall, 2)
    _GDIPlus_GraphicsScaleTransform($hGfxBig, 1 / $fScale, 1 / $fScale)
    _GDIPlus_GraphicsSetInterpolationMode($hGfxBig, 2)

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

    _GDIPlus_GraphicsDrawImage($hGfxSmall, $hBitmap, 0, 0)
    _GDIPlus_GraphicsDrawImage($hGfxBig, $hBmpSmall, 0, 0)

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

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

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

    Func _Exit()
    _GDIPlus_BitmapDispose($hImage)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

    [/autoit]

    mfgE