Bilder anschauen

    • Offizieller Beitrag

    So?

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>

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

    $Form1 = GUICreate("Picture Viewer", 625, 443, -1, -1, -1, $WS_EX_TOOLWINDOW)
    $Button1 = GUICtrlCreateButton("Öffnen...", 0, 416, 73, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    Global $p

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Pic1 = FileOpenDialog("Wählen Sie ein Bild.", @DesktopDir & "\", "(*.jpg;*.png)")
    GUICtrlDelete($p)
    $p = GUICtrlCreatePic($Pic1, 0, 0, 617, 417, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    EndSwitch
    WEnd

    [/autoit]
  • Hallo meinnameisthase,

    dann teste einmal dieses Skript:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>

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

    $Form1 = GUICreate("Picture Viewer", 625, 443, -1, -1, -1, $WS_EX_TOOLWINDOW)
    $Button1 = GUICtrlCreateButton("Öffnen...", 0, 416, 73, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    Global $p

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Pic1 = FileOpenDialog("Wählen Sie ein Bild.", @DesktopDir & "\", "(*.jpg;*.png)")
    $hImage = _GDIPlus_ImageLoadFromFile($Pic1)
    $iW = _GDIPlus_ImageGetWidth($hImage)
    $iH = _GDIPlus_ImageGetHeight($hImage)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()

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

    GUICtrlDelete($p)
    $p = GUICtrlCreatePic($Pic1, 0, 0, $iW, $iH)
    EndSwitch
    WEnd

    [/autoit]

    mfg autoBert

  • Hallo meinnameisthase,

    bei diesem Skript, wird das Bild skaliert so dass das Verhältnis Breite/Höhe gleich bleibt aber das Bild immer die Breite von ~ 617 Pixeln hat:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>

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

    $Form1 = GUICreate("Picture Viewer", 625, 443, -1, -1, -1, $WS_EX_TOOLWINDOW)
    $Button1 = GUICtrlCreateButton("Öffnen...", 0, 416, 73, 25, $WS_GROUP)
    GUISetState(@SW_SHOW)
    Global $p

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $Pic1 = FileOpenDialog("Wählen Sie ein Bild.", @DesktopDir & "\", "(*.jpg;*.png)")
    _GDIPlus_Startup()
    $hImage = _GDIPlus_ImageLoadFromFile($Pic1)
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
    Local $iRatio = $iWidth / $iHeight
    ConsoleWrite("Orig.: " & $iWidth & " " & $iHeight & " " & $iRatio & @CRLF)
    If $iRatio >= 1 Then
    $iWidth = 617
    $iHeight = $iWidth / $iRatio
    Else
    $iHeight = 417
    $iWidth = $iHeight * $iRatio
    EndIf
    ConsoleWrite("New : " & $iWidth & " " & $iHeight & " " & $iRatio & @CRLF)
    GUICtrlDelete($p)
    $p = GUICtrlCreatePic($Pic1, 0, 0, $iWidth, $iHeight)
    EndSwitch
    WEnd

    [/autoit]

    mfg autoBert

  • Hier eine weitere Möglichkeit, ohne Skalierung :)

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include<gdiplus.au3>
    Global Const $SS_REALSIZEIMAGE = 0x0800
    $viewer = GUICreate("viewer", 633, 447, 0, 0)
    $Button1 = GUICtrlCreateButton("Button1", 0, 420, 192, 24, $WS_GROUP)
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    case $Button1
    $path= FileOpenDialog("Wählen Sie ein Bild.", @DesktopDir & "\", "(*.jpg;*.png)")
    $Pic1 = GUICtrlCreatePic($path, 0,0, 0, 0, $SS_REALSIZEIMAGE)
    _gdiplus_startup()
    $Imagegdi = _GDIPlus_ImageLoadFromFile($Path)
    $Width = _GDIPlus_ImageGetWidth($Imagegdi)
    $Height = _GDIPlus_ImageGetHeight($Imagegdi)
    winmove("viewer", "", "", "", $width, $height+50)
    guictrldelete($button1)
    $button1= guictrlcreatebutton("Bild hinzufügen", 0, $height, 100, 20)
    EndSwitch
    WEnd

    [/autoit]

    [align=center]Meine Werke mit der Irrlicht Engine
    AutoIt Picture Viewer Dreidimensionaler Bildbetrachter
    Mr Bubble 3D Neue Interpretation des Flashklassikers Bubble trouble