GDI String Zeichnen Problem

  • Hallo,

    folgendes Problem:

    Ich habe in einer Datei Stringangaben die auf eine GDI Grafik
    gezeichnet werden müssen. Das klappt leider nicht.
    Die Grafikdatei sollte ohne eine Gui zu öffnen direkt mit den Stringangaben gezeichnet werden.

    Das ist die Textdatei (im Anhang)

    Spoiler anzeigen


    3|3|||||||||||||
    Text 1|Arial|0|12.2449388504028|-96.2585067749023|200|60|0x03F66B98|0x03F66E60|65180408|65180720||||
    Text 2|Arial|0|16.3265705108643|-20.7483043670654|77.5510158538818|20.408164024353|0x03E9ACD8|0x03F66E60|65641688|65350072||||
    Text 3|Arial|0|83.6735076904297|14.6258459091187|77.551|20.408|0x03E9AD30|0x03F66E60|65359240|65350376||||

    So ist die Stringdatei aufgebaut

    [autoit]


    ;0=sText 1=sFont 2=iStyle 3=iX 4=iY 5=iW 6=iH 7=hFormat 8=hFamily 9=hPath 10=Brush

    [/autoit]


    also alles was zum Zeichnen benötigt wird.

    Diese Datei habe ich nun als 2DArray eingelesen

    [autoit]


    _FileReadToArray2D($sFile,$anewFile,"|")

    [/autoit]

    Diese Daten sollten nun kpl. mit der Grafikdatei abgespeichert werden
    Farben, Position ... ist alles enthalten.

    [autoit]


    _GDIPlus_ImageSaveToFile($h_Bitmap, @ScriptDir & "\Ilse.jpg")

    [/autoit]

    Aber die Texte kommen da nie an.... :(

    Hier mal das kpl. Script

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <File.au3>
    #include <Array.au3>

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

    Global $sFile = @ScriptDir & "\ilse.txt"
    Global $anewFile

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

    _FileReadToArray2D($sFile,$anewFile,"|")

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

    _arraydisplay($anewFile); Das sind die Font Daten...

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

    _GDIPlus_Startup ()
    ;$h_Image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Hunde.jpg")
    $h_Image = _GDIPlus_ImageLoadFromFile (FileOpenDialog ('Bild auswählen', @ScriptDir, 'Bilder (*.jpg)'))
    If Not $h_Image Then Exit _GDIPlus_Shutdown ()
    $i_Width = _GDIPlus_ImageGetWidth ($h_Image)
    $i_Height = _GDIPlus_ImageGetHeight ($h_Image)

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

    $h_Gui = GUICreate ('', $i_Width, $i_Height + 20)

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

    $h_Graphics = _GDIPlus_GraphicsCreateFromHWND ($h_Gui)
    $h_Bitmap = _GDIPlus_BitmapCreateFromGraphics ($i_Width, $i_Height, $h_Graphics)
    $h_Buffer = _GDIPlus_ImageGetGraphicsContext ($h_Bitmap)
    _WinAPI_RedrawWindow ($h_Gui, 0, 0, 0x0002)

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

    GUIRegisterMsg (0x000F, 'WM_PAINT')

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

    OnAutoItExitRegister ('_OnExit')
    GUISetState (@SW_SHOW, $h_Gui)

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

    While True
    Switch GUIGetMsg ()
    Case $GUI_EVENT_CLOSE

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

    Exit

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

    EndSwitch
    WEnd

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

    ;# Hier sollen die Strings auf das Bild gezeichnet werden!
    Func WM_PAINT ()
    _GDIPlus_GraphicsClear ($h_Buffer)
    _GDIPlus_GraphicsDrawImageRect ($h_Buffer, $h_Image, 0, 0, $i_Width, $i_Height)

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

    Local $hContext = _GDIPlus_ImageGetGraphicsContext($h_Bitmap)

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

    For $i = 1 To $anewFile[0][0] ; Hier werden die ganzen vorhandenen Strings gezeichnet
    ; So ist die Textdatei aufgebaut
    ;0=sText 1=sFont 2=iStyle 3=iX 4=iY 5=iW 6=iH 7=hFormat 8=hFamily 9=hPath 10=Brush
    _GDIPlus_GraphicsDrawStringCustom ($h_Buffer, $anewFile[$i][0],$anewFile[$i][3],$anewFile[$i][4],$anewFile[$i][7],$anewFile[$i][7],$anewFile[$i][1])

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

    Next

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

    _GDIPlus_GraphicsDrawImageRect ($h_Graphics, $h_Bitmap, 0, 0, $i_Width, $i_Height)

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

    EndFunc

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

    Func _OnExit ()

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

    WM_PAINT()

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

    _GDIPlus_ImageSaveToFile($h_Bitmap, @ScriptDir & "\Ilse.jpg")

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

    _GDIPlus_GraphicsDispose ($h_Graphics)
    _GDIPlus_BitmapDispose ($h_Bitmap)
    _GDIPlus_GraphicsDispose ($h_Buffer)
    _GDIPlus_ImageDispose ($h_Image)
    _GDIPlus_Shutdown ()
    EndFunc

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

    ; #FUNCTION# ===================================================================
    ; Name ..........: _GDIPlus_GraphicsDrawStringCustom
    ; Description ...: Draw a customized string
    ; AutoIt Version : v3.3.6.1
    ; Syntax ........: _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color[, $i_Align = 0[, $i_Weight = 0[, $s_Font = 'Arial']]])
    ; Parameter(s): .: $h_Graphics - Handle to a Graphics object
    ; $s_String - String to be drawn
    ; $n_X - X coordinate where the string will be drawn
    ; $n_Y - Y coordinate where the string will be drawn
    ; $n_Size - Font size to use for drawing
    ; $b_Color - Alpha, Red, Green and Blue components
    ; $i_Align - The alignment can be one of the following:
    ; |0 - The text is aligned to the left
    ; |1 - The text is centered
    ; |2 - The text is aligned to the right
    ; $i_Weight - The style of the typeface. Can be a combination of the following:
    ; |0 - Normal weight or thickness of the typeface
    ; |1 - Bold typeface
    ; |2 - Italic typeface
    ; |4 - Underline
    ; |8 - Strikethrough
    ; $s_Font - Name of the Font Family
    ; Return Value ..: Success - True
    ; Failure - False
    ; Author(s) .....: $var
    Func _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color, $i_Align = 0, $i_Weight = 0, $s_Font = 'Arial')
    Local $a_CreateSolidFill, $a_CreateStringFormat, $a_CreateFontFamilyFromName, $a_CreateFont, $t_Struct, $p_Layout, $a_Return
    $a_CreateSolidFill = DllCall ($ghGDIPDll, 'int', 'GdipCreateSolidFill', 'int', $b_Color, 'dword*', 0)
    $a_CreateStringFormat = DllCall ($ghGDIPDll, 'int', 'GdipCreateStringFormat', 'int', 0, 'word', 0, 'ptr*', 0)
    $a_CreateFontFamilyFromName = DllCall ($ghGDIPDll, 'int', 'GdipCreateFontFamilyFromName', 'wstr', $s_Font, 'ptr', 0, 'handle*', 0)
    $a_CreateFont = DllCall ($ghGDIPDll, 'int', 'GdipCreateFont', 'handle', $a_CreateFontFamilyFromName[3], 'float', $n_Size, 'int', $i_Weight, 'int', 3, 'ptr*', 0)
    $t_Struct = DllStructCreate ($tagGDIPRECTF)
    $p_Layout = DllStructGetPtr ($t_Struct)
    DllStructSetData ($t_Struct, 'X', $n_X)
    DllStructSetData ($t_Struct, 'Y', $n_Y)
    DllStructSetData ($t_Struct, 'Width', 0)
    DllStructSetData ($t_Struct, 'Height', 0)
    DllCall ($ghGDIPDll, 'int', 'GdipSetStringFormatAlign', 'handle', $a_CreateStringFormat[3], 'int', $i_Align)
    $a_Return = DllCall ($ghGDIPDll, 'int', 'GdipDrawString', 'handle', $h_Graphics, 'wstr', $s_String, 'int', -1, 'handle', $a_CreateFont[5], _
    'ptr', $p_Layout, 'handle', $a_CreateStringFormat[3], 'handle', $a_CreateSolidFill[2])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteFont', 'handle', $a_CreateFont[5])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteFontFamily', 'handle', $a_CreateFontFamilyFromName[3])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteStringFormat', 'handle', $a_CreateStringFormat[3])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteBrush', 'handle', $a_CreateSolidFill[2])
    Return $a_Return[0] = 0
    EndFunc ;==> _GDIPlus_GraphicsDrawStringCustom

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

    ;==========================================================================================================================================
    ; Function: _FileReadToArray2D($FILEPATH, $ARRAY [, $DELIM=-1])
    ;
    ; Description: Read 1D/2D array from file, if $DELIM is given (<> -1) 2D array will created
    ;
    ; Parameter(s): $FILEPATH - path/filename of the file to read in an array
    ; $ARRAY - array variable to hold readed data
    ; optional $DELIM - delimiter for 2D-array entries, default -1 (none 2D-array)
    ;
    ; Requirement(s): None
    ;
    ; Return Value(s): On Success - Returns -1
    ; On Failure - Returns 0 and sets @error = 1 (given file are not seperated with given delimiter or count of delimiters
    ; are not equal); @error = 2 (unable to open filepath)
    ;
    ; Note: If given file is delimited to create 2D-array ALL lines need the same count of delimiters, otherwise an error occurs!
    ;
    ; Author(s): BugFix ( [email='bugfix@autoit.de'][/email] )
    ;==========================================================================================================================================
    Func _FileReadToArray2D($FILEPATH, ByRef $ARRAY, $DELIM=-1)
    Local $fh = FileOpen($FILEPATH, 0), $line, $var, $n = 1
    If $fh = -1 Then
    SetError(2)
    Return 0
    EndIf
    If $DELIM <> -1 Then
    $line = FileReadLine($fh, 1)
    $var = StringSplit($line, $DELIM)
    If IsArray($var) Then
    $Ubound2nd = $var[0]
    Local $AR[1][$Ubound2nd]
    $AR[0][0] = 0
    Else
    SetError(1)
    Return 0
    EndIf
    While 1
    $line = FileReadLine($fh, $n)
    If @error = -1 Then ExitLoop
    $var = StringSplit($line, $DELIM)
    If IsArray($var) Then
    ReDim $AR[UBound($AR)+1][$Ubound2nd]
    For $i = 0 To $Ubound2nd-1
    $AR[UBound($AR)-1][$i] = $var[$i+1]
    Next
    $AR[0][0] += 1
    Else
    SetError(1)
    Return 0
    EndIf
    $n += 1
    Wend
    Else
    Local $AR[1]
    $AR[0] = 0
    While 1
    $line = FileReadLine($fh, $n)
    If @error = -1 Then ExitLoop
    ReDim $AR[UBound($AR)+1]
    $AR[UBound($AR)-1] = $line
    $AR[0] += 1
    $n += 1
    WEnd
    EndIf
    FileClose($fh)
    $ARRAY = $AR
    Return -1
    EndFunc ;==>_FileReadToArray2D

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


    Bin schon den ganzen Tag an diesem Problem,
    ich hoffe ihr habt da ne Lösung.

    Liebe Grüße
    Ilse ;)

  • 1. Du kannst keine Handles zu Objekten im Arbeitsspeicher in einer Textdatei speichern und erwarten, dass die beim nächsten Zugriff noch da sind... Der Speicherbereich der von deinem Programm reserviert wird ist weg, nachdem es beendet wurde.
    2. Die Funktion erwartet noch nicht einmal Handles zu Objekten (außer beim ersten Parameter) und kann damit nichts anfangen (besonders nicht wenn die Handles mittlerweile völlig nutzlos sind und zu einem Objekt zeigten, dass gar nichts mit dem Parameter zu tun hat).
    3. Du verwendest für die Parameter $n_Size und $b_Color den selben Parameter ('0x03F66E60' soweit ich sehen kann), d.h. eine nahezu unsichtbare Farbe mit einem Alpha Wert von 3 (fast vollständig transparent) und eine Schriftgröße von 66481760 Punkten. Ich glaube, kein Drucker der Welt ist in der Lage so große Buchstaben zu drucken. Und ob unser Planet dafür genügend Papier und Tinte hat weiß ich auch nicht.
    Das sind so die Knackpunkte die mir aufgefallen sind. Danach hab ich keine Fehler mehr gesucht.

  • Hallo name22,

    ich habe die Schriftgröße, Farbe, Position...
    in das Array exportiert. Da war ein Fehler drin....

    Andere Frage:

    Könnte man die Werte in einer INI speichern,
    dann diese Werte einlesen und anschließend
    mit GDI auf die Grafik zeichnen und speichern????

    Oder gäbe es dann auch Probleme mit Handles...?

    Habe die Datei angehängt!
    Liebe Grüße
    Ilse ;)

    Einmal editiert, zuletzt von Ilse (9. August 2012 um 13:26)

  • Hallo,

    irgendwie versteh ich das nicht.
    Ich lade doch einfach nur die Informationen der Variablen
    Name, Arial x, y aus dem Array.

    Und das soll auf eine Grafik
    Ich kann doch die Werte im Script lesen! (Zeile 60)

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Misc.au3>
    #include <EditConstants.au3>
    #include <WindowsConstants.au3>
    #include <ButtonConstants.au3>
    #include <File.au3>
    #include <Array.au3>

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

    Global $sFile = @ScriptDir & "\ilse.txt"
    Global $anewFile

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

    _FileReadToArray2D($sFile,$anewFile,"|")

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

    _arraydisplay($anewFile); Das sind die Font Daten...

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

    _GDIPlus_Startup ()
    ;$h_Image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Hunde.jpg")
    $h_Image = _GDIPlus_ImageLoadFromFile (FileOpenDialog ('Bild auswählen', @ScriptDir, 'Bilder (*.jpg)'))
    If Not $h_Image Then Exit _GDIPlus_Shutdown ()
    $i_Width = _GDIPlus_ImageGetWidth ($h_Image)
    $i_Height = _GDIPlus_ImageGetHeight ($h_Image)

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

    $h_Gui = GUICreate ('', $i_Width, $i_Height + 20)

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

    $h_Graphics = _GDIPlus_GraphicsCreateFromHWND ($h_Gui)
    $h_Bitmap = _GDIPlus_BitmapCreateFromGraphics ($i_Width, $i_Height, $h_Graphics)
    $h_Buffer = _GDIPlus_ImageGetGraphicsContext ($h_Bitmap)
    _WinAPI_RedrawWindow ($h_Gui, 0, 0, 0x0002)

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

    GUIRegisterMsg (0x000F, 'WM_PAINT')

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

    OnAutoItExitRegister ('_OnExit')
    GUISetState (@SW_SHOW, $h_Gui)

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

    While True
    Switch GUIGetMsg ()
    Case $GUI_EVENT_CLOSE

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

    Exit

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

    EndSwitch
    WEnd

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

    ;# Hier sollen die Strings auf das Bild gezeichnet werden!
    Func WM_PAINT ()
    _GDIPlus_GraphicsClear ($h_Buffer)
    _GDIPlus_GraphicsDrawImageRect ($h_Buffer, $h_Image, 0, 0, $i_Width, $i_Height)

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

    Local $hContext = _GDIPlus_ImageGetGraphicsContext($h_Bitmap)

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

    For $i = 2 To $anewFile[0][0] ; Hier werden die ganzen vorhandenen Strings gezeichnet
    Msgbox(0,"Soll auf die Grafik",$anewFile[$i][0])
    ; So ist die Textdatei aufgebaut
    ;0=sText 1=sFont 2=iStyle 3=iX 4=iY 5=iW 6=iH 7=hFormat 8=hFamily 9=hPath 10=Brush
    _GDIPlus_GraphicsDrawStringCustom ($h_Buffer, $anewFile[$i][0],$anewFile[$i][3],$anewFile[$i][4],$anewFile[$i][7],$anewFile[$i][7],$anewFile[$i][1])

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

    Next

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

    _GDIPlus_GraphicsDrawImageRect ($h_Graphics, $h_Bitmap, 0, 0, $i_Width, $i_Height)

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

    EndFunc

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

    Func _OnExit ()

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

    WM_PAINT()

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

    _GDIPlus_ImageSaveToFile($h_Bitmap, @ScriptDir & "\Ilse.jpg")

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

    _GDIPlus_GraphicsDispose ($h_Graphics)
    _GDIPlus_BitmapDispose ($h_Bitmap)
    _GDIPlus_GraphicsDispose ($h_Buffer)
    _GDIPlus_ImageDispose ($h_Image)
    _GDIPlus_Shutdown ()
    EndFunc

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

    ; #FUNCTION# ===================================================================
    ; Name ..........: _GDIPlus_GraphicsDrawStringCustom
    ; Description ...: Draw a customized string
    ; AutoIt Version : v3.3.6.1
    ; Syntax ........: _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color[, $i_Align = 0[, $i_Weight = 0[, $s_Font = 'Arial']]])
    ; Parameter(s): .: $h_Graphics - Handle to a Graphics object
    ; $s_String - String to be drawn
    ; $n_X - X coordinate where the string will be drawn
    ; $n_Y - Y coordinate where the string will be drawn
    ; $n_Size - Font size to use for drawing
    ; $b_Color - Alpha, Red, Green and Blue components
    ; $i_Align - The alignment can be one of the following:
    ; |0 - The text is aligned to the left
    ; |1 - The text is centered
    ; |2 - The text is aligned to the right
    ; $i_Weight - The style of the typeface. Can be a combination of the following:
    ; |0 - Normal weight or thickness of the typeface
    ; |1 - Bold typeface
    ; |2 - Italic typeface
    ; |4 - Underline
    ; |8 - Strikethrough
    ; $s_Font - Name of the Font Family
    ; Return Value ..: Success - True
    ; Failure - False
    ; Author(s) .....: $var
    Func _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color, $i_Align = 0, $i_Weight = 0, $s_Font = 'Arial')
    Local $a_CreateSolidFill, $a_CreateStringFormat, $a_CreateFontFamilyFromName, $a_CreateFont, $t_Struct, $p_Layout, $a_Return
    $a_CreateSolidFill = DllCall ($ghGDIPDll, 'int', 'GdipCreateSolidFill', 'int', $b_Color, 'dword*', 0)
    $a_CreateStringFormat = DllCall ($ghGDIPDll, 'int', 'GdipCreateStringFormat', 'int', 0, 'word', 0, 'ptr*', 0)
    $a_CreateFontFamilyFromName = DllCall ($ghGDIPDll, 'int', 'GdipCreateFontFamilyFromName', 'wstr', $s_Font, 'ptr', 0, 'handle*', 0)
    $a_CreateFont = DllCall ($ghGDIPDll, 'int', 'GdipCreateFont', 'handle', $a_CreateFontFamilyFromName[3], 'float', $n_Size, 'int', $i_Weight, 'int', 3, 'ptr*', 0)
    $t_Struct = DllStructCreate ($tagGDIPRECTF)
    $p_Layout = DllStructGetPtr ($t_Struct)
    DllStructSetData ($t_Struct, 'X', $n_X)
    DllStructSetData ($t_Struct, 'Y', $n_Y)
    DllStructSetData ($t_Struct, 'Width', 0)
    DllStructSetData ($t_Struct, 'Height', 0)
    DllCall ($ghGDIPDll, 'int', 'GdipSetStringFormatAlign', 'handle', $a_CreateStringFormat[3], 'int', $i_Align)
    $a_Return = DllCall ($ghGDIPDll, 'int', 'GdipDrawString', 'handle', $h_Graphics, 'wstr', $s_String, 'int', -1, 'handle', $a_CreateFont[5], _
    'ptr', $p_Layout, 'handle', $a_CreateStringFormat[3], 'handle', $a_CreateSolidFill[2])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteFont', 'handle', $a_CreateFont[5])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteFontFamily', 'handle', $a_CreateFontFamilyFromName[3])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteStringFormat', 'handle', $a_CreateStringFormat[3])
    DllCall ($ghGDIPDll, 'int', 'GdipDeleteBrush', 'handle', $a_CreateSolidFill[2])
    Return $a_Return[0] = 0
    EndFunc ;==> _GDIPlus_GraphicsDrawStringCustom

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

    ;==========================================================================================================================================
    ; Function: _FileReadToArray2D($FILEPATH, $ARRAY [, $DELIM=-1])
    ;
    ; Description: Read 1D/2D array from file, if $DELIM is given (<> -1) 2D array will created
    ;
    ; Parameter(s): $FILEPATH - path/filename of the file to read in an array
    ; $ARRAY - array variable to hold readed data
    ; optional $DELIM - delimiter for 2D-array entries, default -1 (none 2D-array)
    ;
    ; Requirement(s): None
    ;
    ; Return Value(s): On Success - Returns -1
    ; On Failure - Returns 0 and sets @error = 1 (given file are not seperated with given delimiter or count of delimiters
    ; are not equal); @error = 2 (unable to open filepath)
    ;
    ; Note: If given file is delimited to create 2D-array ALL lines need the same count of delimiters, otherwise an error occurs!
    ;
    ; Author(s): BugFix ( [email='bugfix@autoit.de'][/email] )
    ;==========================================================================================================================================
    Func _FileReadToArray2D($FILEPATH, ByRef $ARRAY, $DELIM=-1)
    Local $fh = FileOpen($FILEPATH, 0), $line, $var, $n = 1
    If $fh = -1 Then
    SetError(2)
    Return 0
    EndIf
    If $DELIM <> -1 Then
    $line = FileReadLine($fh, 1)
    $var = StringSplit($line, $DELIM)
    If IsArray($var) Then
    $Ubound2nd = $var[0]
    Local $AR[1][$Ubound2nd]
    $AR[0][0] = 0
    Else
    SetError(1)
    Return 0
    EndIf
    While 1
    $line = FileReadLine($fh, $n)
    If @error = -1 Then ExitLoop
    $var = StringSplit($line, $DELIM)
    If IsArray($var) Then
    ReDim $AR[UBound($AR)+1][$Ubound2nd]
    For $i = 0 To $Ubound2nd-1
    $AR[UBound($AR)-1][$i] = $var[$i+1]
    Next
    $AR[0][0] += 1
    Else
    SetError(1)
    Return 0
    EndIf
    $n += 1
    Wend
    Else
    Local $AR[1]
    $AR[0] = 0
    While 1
    $line = FileReadLine($fh, $n)
    If @error = -1 Then ExitLoop
    ReDim $AR[UBound($AR)+1]
    $AR[UBound($AR)-1] = $line
    $AR[0] += 1
    $n += 1
    WEnd
    EndIf
    FileClose($fh)
    $ARRAY = $AR
    Return -1
    EndFunc ;==>_FileReadToArray2D

    [/autoit]


    Hab die Textdatei erneuert


    Grüße
    Ilse :(

  • ... Liest du was ich schreibe? 8|
    Natürlich kannst du die Werte lesen. Und? Erstens lässt du nur den ersten Wert per MsgBox ausgeben, zweitens verwendest du immer noch die falschen Werte für manche Parameter und drittens Hast du immer noch Handles in deiner Datei drin? Was machen die Handles da!? Ich hab dir doch schon erklärt, dass Handles nicht mehr gültig sind wenn der Prozess beendet wird der sie erzeugt hat... Handles sind im Grunde Adressen zu Objekten im Arbeitsspeicher. Der Arbeitsspeicher wird aber erstens gelöscht wenn du den Computer runterfährst und zweitens wird der Teil des Arbeitsspeichers den ein Script sich reserviert (wo dann auch die GDI+ Objekte nachher sind) gelöscht nachdem ein Script sich beendet. Diese Hexadezimalzahlen sind nutzlos wenn du sie in eine Datei schreibst und später in einem anderen Programm verwenden willst!
    Das ist aber nicht das einzige Problem. Die Funktion die du aufrufst erwartet nirgendwo (außer bei der Grafik) ein Handle! Wieso willst du da ubedingt eins angeben?
    Du kannst doch eine Funktionsbeschreibung lesen, oder?

    Spoiler anzeigen
    [autoit]

    ; Parameter(s): .: $h_Graphics - Handle to a Graphics object
    ; $s_String - String to be drawn
    ; $n_X - X coordinate where the string will be drawn
    ; $n_Y - Y coordinate where the string will be drawn
    ; -> $n_Size - Font size to use for drawing - Kein Handle, sondern eine normale Zahl sollst du hier angeben...
    ; -> $b_Color - Alpha, Red, Green and Blue components - Hier sollst du einen ARGB Farbwert angeben, auch kein Handle... (z.B. 0xFFAE0033)
    ; $i_Align - The alignment can be one of the following:
    ; |0 - The text is aligned to the left
    ; |1 - The text is centered
    ; |2 - The text is aligned to the right
    ; $i_Weight - The style of the typeface. Can be a combination of the following:
    ; |0 - Normal weight or thickness of the typeface
    ; |1 - Bold typeface
    ; |2 - Italic typeface
    ; |4 - Underline
    ; |8 - Strikethrough
    ; $s_Font - Name of the Font Family

    [/autoit]


    Dann gibst du auch noch für 2 verschiedene Parameter, die verschiedene Werte in komplett verschiedenen Dimensionen erwarten den gleichen Wert an:
    _GDIPlus_GraphicsDrawStringCustom ($h_Buffer, $anewFile[$i][0],$anewFile[$i][3],$anewFile[$i][4],$anewFile[$i][7],$anewFile[$i][7],$anewFile[$i][1])
    Wieso? Jetzt verwendest du eine nahezu transparente Farbe und eine unmöglich große Schriftgröße... Das kann doch nie im Leben stimmen....

  • Hallo name22,

    erstmal ein dankeschön für deine Erklärungen
    klar lese ich was du schreibst. ;)
    Hab auch versucht das nachzuvollziehen
    und den Fehler nicht gleich gefunden.

    Das Problem war folgendes:
    Die Textdatei wurde mit den Werten falsch generiert.
    Deswegen war die Transparenz, Handles...u.s.w bereits in der Textdatei.
    Ich bin davon ausgegangen daß die Werte stimmen.

    Diese falschen Datei wurde eingelesen.

    Nun, ich habe dann die Datei von Hand kpl. neu aufgebaut
    und siehe da, es hat funktioniert.

    Dank deiner Hilfe...


    Liebe Grüße
    Ilse ;)