Hallo zusammen,
ich bin jetzt schon stundenlang an diesem Problem.
hm...wie erklär ich's...
Folgendes:
1. Ich öffne ein Bild (ok)
2. Ich wähle den Menüpunkt (ok)
3. Ich drücke die Pfeiltasten zum positionieren des Textes
4. Wenn ich den nächsten Eintrag aus dem Menü wähle und ich positioniere stimmt es nicht mehr.
(Müsste quasie etliche _Update Func und Case...machen...)
Das Problem:
Es können mehrere Menüeinträge sein
Ich möchte das gerne so machen:
1. Text wählen, positionieren
2. Text wählen positionieren u.s.w.
3. Speichern fertig
Spoiler anzeigen
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <gdiplus.au3>
#include <misc.au3>
Global $afont[8]
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(FileOpenDialog("Bild auswählen", @ScriptDir, "Bilder (*.jpg)"))
If Not $hImage Then Exit _GDIPlus_Shutdown()
$iW = _GDIPlus_ImageGetWidth($hImage)
$iH = _GDIPlus_ImageGetHeight($hImage)
$x = 140
$y = 110
$Form1 = GUICreate("Form1", $iW, $iH)
$MenuItem1 = GUICtrlCreateMenu("Texte und Schriften")
$mnText1 = GUICtrlCreateMenuItem("Hunde", $MenuItem1)
$mnText2 = GUICtrlCreateMenuItem("Katzen", $MenuItem1)
GUISetState()
Global $Text[4]
[/autoit] [autoit][/autoit] [autoit]$Text[0] = "Welpen"
$Text[1] = "Hunde"
$Text[2] = "Katzen"
$Text[3] = "Vögel"
;_ArrayDisplay($Text)
[/autoit] [autoit][/autoit] [autoit]$hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
;$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphics)
$hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2)
DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hCtxt, "int", 4)
_GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
;$aFont = _ChooseFont()
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate($afont[2])
$hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
$tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
Global $hDLL = DllOpen("user32.dll")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\Ilse.jpg")
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_GraphicsDispose($hCtxt)
_GDIPlus_Shutdown()
DllClose($hDLL)
GUIDelete()
Exit
Case $mnText1
_Schrift1()
Case $mnText2
_Schrift2()
EndSwitch
If _IsPressed("25") Then
$x -= 1
DllStructSetData($tLayout, "X", $x)
Update()
ElseIf _IsPressed("27") Then
$x += 1
DllStructSetData($tLayout, "X", $x)
Update()
ElseIf _IsPressed("26") Then
$y -= 1
DllStructSetData($tLayout, "Y", $y)
Update()
ElseIf _IsPressed("28") Then
$y += 1
DllStructSetData($tLayout, "Y", $y)
Update()
EndIf
WEnd
Func Update()
;MsgBox(0,"",$x&"-"&$y)
_GDIPlus_GraphicsDrawImage($hCtxt, $hImage, 0, 0)
_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
;_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text2, $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
Return 1
EndFunc ;==>Update
Func _Schrift1()
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
$afont = _ChooseFont()
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate($afont[2])
$hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
$tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[1], $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
Global $hDLL = DllOpen("user32.dll")
EndFunc ;==>_Schrift1
Func _Schrift2()
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
$afont = _ChooseFont()
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000 + $afont[7])
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate($afont[2])
$hFont = _GDIPlus_FontCreate($hFamily, $afont[3], $afont[1])
$tLayout = _GDIPlus_RectFCreate($x, $y, 1000, 1000)
_GDIPlus_GraphicsDrawStringEx($hCtxt, $Text[2], $hFont, $tLayout, $hFormat, $hBrush)
_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0)
Global $hDLL = DllOpen("user32.dll")
EndFunc ;==>_Schrift2
...hoffe ihr habt da ne Idee
Liebe Grüße
Ilse