Bitmap mittels GDI+ mit CopyRight u. Zeitstempel versehen

  • Hallo ihr Könner,
    kann mir jemand sagen/zeigen, wie ich folgendes mache:

    Ich möchte ein BMP laden, einen Text unten rechts drüberlegen und dann das BMP im gleichen Verzeichnis unter gleichem Namen wieder abspeichern.

    Vielen Dank für Eure Hilfe.

    P.S.: Autoit ist Super, das Forum sowieso!!!!!!!

    Einmal editiert, zuletzt von fschaef (20. März 2010 um 13:31)

  • Hab ich kurz zusammengebastelt :D Ist nicht sehr ordentlich, aber müsste funktionieren.

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>

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

    _GDIPlus_Startup()

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

    $hImage = _GDIPlus_BitmapCreateFromFile(@DesktopDir & "\Test.jpg")
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)

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

    $String = @HOUR & ":" & @MIN & ":" & @SEC

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

    $hBrush = _GDIPlus_BrushCreateSolid(0xA900007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 40, 0)
    $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $String, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $String, $hFont, $aInfo[0], $hFormat, $hBrush)

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

    _GDIPlus_ImageSaveToFile($hImage, @DesktopDir & "\beispiel.jpg")

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

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

    [/autoit]

    Habe es mal ein wenig erweitert (nur so als Beispiel)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GuiComboBoxEx.au3>
    #include <GDIPlus.au3>
    #include <Misc.au3>
    #include <File.au3>

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

    _GDIPlus_Startup()

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

    $hImage = _GDIPlus_BitmapCreateFromFile(FileOpenDialog("Bild öffnen", @UserProfileDir & "\Pictures", "Bilder (*.jpg;*.jpeg;*.bmp;*.gif;*.png)"))
    $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)

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

    $Wasserzeichen = GUICreate("Wasserzeichen", 222, 107, 192, 124)
    $Input = GUICtrlCreateInput("", 8, 72, 121, 21)
    GUICtrlSetLimit(-1, 10)
    $Combo = _GUICtrlComboBoxEx_Create($Wasserzeichen, "Uhrzeit|Datum|Computername|Benutzername|Benutzerdefiniert", 8, 40, 145, 25)
    $OK = GUICtrlCreateButton("OK", 136, 72, 75, 25, $WS_GROUP)
    $Label = GUICtrlCreateLabel("Bitte Text für das Wasserzeichen angeben:", 8, 8, 208, 17)
    GUISetState()

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $OK
    Switch _GUICtrlComboBoxEx_GetCurSel($Combo)
    Case 0
    $String = @HOUR & ":" & @MIN & ":" & @SEC
    GUIDelete()
    ExitLoop
    Case 1
    $String = @MDAY & "." & @MON & "." & @YEAR
    GUIDelete()
    ExitLoop
    Case 2
    $String = @ComputerName
    GUIDelete()
    ExitLoop
    Case 3
    $String = @UserName
    GUIDelete()
    ExitLoop
    Case 4
    If Not StringReplace(GUICtrlRead($Input), " ", "") = "" Then
    $String = GUICtrlRead($Input)
    GUIDelete()
    ExitLoop
    EndIf
    EndSwitch
    EndSwitch
    WEnd

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

    $hBrush = _GDIPlus_BrushCreateSolid("0x" & Hex(InputBox("Transparenz", "(0-255)"), 2) & StringTrimLeft(_ChooseColor(2), 2))
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 40, 0)
    $tLayout = _GDIPlus_RectFCreate(0, 0, 0, 0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $String, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $String, $hFont, $aInfo[0], $hFormat, $hBrush)

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

    _GDIPlus_ImageSaveToFile($hImage, _Path())

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

    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

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

    Func _Path()
    Local $szDrive, $szDir, $szFName, $szExt
    $Path = FileSaveDialog("Speichern unter", @ScriptDir, "Bilder (*.jpg;*.jpeg;*.gif;*.png;*.bmp)")
    $PathSplit = _PathSplit($Path, $szDrive, $szDir, $szFName, $szExt)
    If Not ($PathSplit[4] = ".jpg" Or $PathSplit[4] = ".gif" Or $PathSplit[4] = ".png" Or $PathSplit[4] = ".bmp") Then
    MsgBox(16, "Fehler", "Bitte Erweiterung angeben")
    _Path()
    EndIf
    Return $Path
    EndFunc ;==>_Path

    [/autoit]