_GDIPlus_GraphicsDraw spiegeln und drehen

  • Hallo

    ich arbeite momentan an ein programm was mithilfe von Kordinaten Also X und Y eine zeichnung erstellt mein problem ist nun das er sie auf den kopf zeichnet
    hier ist mein Code:

    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Array.au3>
    #include <File.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <WindowsConstants.au3>
    Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
    Global $g_iMouseX, $g_iMouseY
    Local $hGUI, $hGraphic, $hPen,$aArray,$g_hBmp_Buffer,$g_hGraphics
    Local $g_iMouseX,$g_iMouseY,$lParam

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

    $hGUI = GUICreate("GDI+", 1000, 300)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    If Not _FileReadToArray("a2.din", $aArray, 0) Then
    MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    EndIf

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

    For $x = 1 To UBound($aArray)-1
    If StringInStr($aArray[$x],"G00 X") Then
    ;~ _GDIPlus_GraphicsDrawLine($hGraphic, StringTrimLeft($spl[2],1), StringTrimLeft($spl[3],1), StringTrimLeft($spl2[2],1), StringTrimLeft($spl2[3],1), $hPen)
    ElseIf StringInStr($aArray[$x],"G01 X") Then
    $spl = StringSplit($aArray[$x]," ")
    $spl2 = StringSplit($aArray[$x-1]," ")
    If $spl[0] >= 3 and $spl2[0] >= 3 Then
    IF StringTrimLeft($spl2[2],1) = "-0.1" Then
    Else
    _GDIPlus_GraphicsDrawLine($hGraphic, StringTrimLeft($spl[2],1), StringTrimLeft($spl[3],1), StringTrimLeft($spl2[2],1), StringTrimLeft($spl2[3],1), $hPen)
    EndIf
    EndIf
    EndIf
    Next

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

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

    [/autoit]

    im anhang ist die cordinaten datei

  • Versuchs mal so:

    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Array.au3>
    #include <File.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <WindowsConstants.au3>
    Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
    Global $g_iMouseX, $g_iMouseY
    Local $hGUI, $hGraphic, $hPen,$aArray,$g_hBmp_Buffer,$g_hGraphics
    Local $g_iMouseX,$g_iMouseY,$lParam

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

    $hGUI = GUICreate("GDI+", 1000, 300)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    If Not _FileReadToArray("a2.din", $aArray, 0) Then
    MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    EndIf

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

    For $x = 1 To UBound($aArray)-1
    If StringInStr($aArray[$x],"G00 X") Then
    ;~ _GDIPlus_GraphicsDrawLine($hGraphic, StringTrimLeft($spl[2],1), StringTrimLeft($spl[3],1), StringTrimLeft($spl2[2],1), StringTrimLeft($spl2[3],1), $hPen)
    ElseIf StringInStr($aArray[$x],"G01 X") Then
    $spl = StringSplit($aArray[$x]," ")
    $spl2 = StringSplit($aArray[$x-1]," ")
    If $spl[0] >= 3 and $spl2[0] >= 3 Then
    IF StringTrimLeft($spl2[2],1) = "-0.1" Then
    Else
    _GDIPlus_GraphicsDrawLine($hGraphic, StringTrimLeft($spl[2],1), 300 -StringTrimLeft($spl[3],1), StringTrimLeft($spl2[2],1), 300 -StringTrimLeft($spl2[3],1), $hPen)
    EndIf
    EndIf
    EndIf
    Next

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

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

    [/autoit]
  • Hier mein Vorschlag:

    Spoiler anzeigen
    [autoit]


    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <Array.au3>
    #include <File.au3>
    #include <GDIPlus.au3>
    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <WindowsConstants.au3>
    Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hImage
    Global $g_iMouseX, $g_iMouseY
    Local $hGUI, $hGraphic, $hPen,$aArray,$g_hBmp_Buffer,$g_hGraphics
    Local $g_iMouseX,$g_iMouseY,$lParam, $fY1, $fY2, $fY = 180.0

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

    $hGUI = GUICreate("GDI+", 1000, 300)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2)
    If Not _FileReadToArray("a2.din", $aArray, 0) Then
    MsgBox($MB_SYSTEMMODAL, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file.
    EndIf
    $hPen = _GDIPlus_PenCreate(0xFF101060)
    For $x = 1 To UBound($aArray)-1
    If StringInStr($aArray[$x],"G00 X") Then
    ;~ _GDIPlus_GraphicsDrawLine($hGraphic, StringTrimLeft($spl[2],1), StringTrimLeft($spl[3],1), StringTrimLeft($spl2[2],1), StringTrimLeft($spl2[3],1), $hPen)
    ElseIf StringInStr($aArray[$x],"G01 X") Then
    $spl = StringSplit($aArray[$x]," ")
    $spl2 = StringSplit($aArray[$x-1]," ")
    If $spl[0] >= 3 and $spl2[0] >= 3 Then
    IF StringTrimLeft($spl2[2],1) = "-0.1" Then

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

    Else
    $fY1 = -StringTrimLeft($spl[3],1) + 2 * $fY ;y1 Punkt an der Koordinate fY spiegeln
    $fY2 = -StringTrimLeft($spl2[3],1) + 2 * $fY ;y2 Punkt an der Koordinate fY spiegeln
    _GDIPlus_GraphicsDrawLine($hGraphic, StringTrimLeft($spl[2],1),$fY1, StringTrimLeft($spl2[2],1), $fY2, $hPen)
    EndIf
    EndIf
    EndIf
    Next

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

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    ; Clean up resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()

    [/autoit]


    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    Einmal editiert, zuletzt von UEZ (18. November 2014 um 11:11)

  • Theoretisch, wenn das Projekt universell bleiben soll und beliebige Daten importieren können soll, müsste man noch zwei weitere Schritte einbauen.

    1. prüfen wie Groß die maximalen Parameter von X und Y der Grafik sind und daran die Form anpassen (gegebenenfalls sogar die Grafik kleiner zeichnen - die Koordinaten durch Faktor "X" teilen)

    2. Mithilfe des größten Parameter von Y der geladenen Koordinaten, den Punkt der Spiegelachse festlegen.

    Einmal editiert, zuletzt von KloMeister (18. November 2014 um 11:07)