Bild proportional darstellen

  • Hallo, ich möchte gern ein Bild in ein GUI einbauen, jedoch wird es ja mit GUICtrlCreatePic "verzerrt" angezeigt, ist es möglich, das das Bild relativ angezeigt wird, also orginale seitenverhältnisse beibehält.. ich hoffe ihr wisst was ich meine

    Einmal editiert, zuletzt von ErrorKid (6. November 2010 um 04:31) aus folgendem Grund: Präfix und Titel

  • Wenns nur 1 Bild is schau doch einfach fix in Paint nach wie groß es ist und pass dein GUICtrlCreatePic an.

  • Hallo,

    $SS_CENTERIMAGE + $SS_REALSIZECONTROL

    [autoit]

    #include <StaticContants.au3>
    If Not IsDeclared("SS_REALSIZECONTROL") Then
    Global Const $SS_REALSIZECONTROL = 0x40
    EndIf

    [/autoit]
  • hmm, leider funktioniert es nicht :(

    [autoit]


    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    If Not IsDeclared("SS_REALSIZECONTROL") Then
    Global Const $SS_REALSIZECONTROL = 0x40
    EndIf

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

    $Form2 = GUICreate("Form2", 1143, 544, 192, 123)
    $Pic1 = GUICtrlCreatePic("C:\test.jpg", 8, 8, 100, 100, BitOR($SS_NOTIFY, $SS_CENTERIMAGE, $SS_REALSIZECONTROL))
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

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


    was mach ich falsch?

    MfG

  • Hi,

    hol dir mal diese tolle UDF
    ExtProp.au3
    und bind sie so in dein Skript ein ;)

    Spoiler anzeigen
    [autoit]

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

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

    $Form2 = GUICreate("Form2", 1143, 544, 192, 123)
    $file = "C:\test.jpg"
    $w = int(_GetExtProperty($file, 27)) ; Funktion aus der UDF ExtProp
    $h = int(_GetExtProperty($file, 28)) ; Funktion aus der UDF ExtProp
    $Pic1 = GUICtrlCreatePic($file, 8, 8, $w, $h)
    GUISetState(@SW_SHOW)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]
  • Das geht aber nur, solange das Bild kleiner ist als die GUI. Es wird dabei nicht das Bild (proportional) verkleinert.

    Danke Oscar, du hast verstanden, um was es geht.. sry ich hab mich aber die ganze zeit falsch ausgedrückt! ich meine nicht relativ sondern proportional.. SRY :pinch:

    ich hab ein gui, bei dem des Picture Control 150x150 groß ist.. in diesem control soll ein bild (beispielsweiße 1500x3000) proportional angezeit (es wird also auf 150x300 runterskaliert..)

    egal, ich muss mir mal dein (Oscar) script nochmal genauer anschauen und bisschen umbauen, im prinzip macht es ja schon das richtige ;) DANKE an alle antworten ;)

  • Hilft dir das vielleicht weiter (ohne GDI+ ;) )?

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>

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

    $iFile = FileOpenDialog("Bitte ein Bild selektieren", "", "Bild (*.jpg;*.png;*.bmp;*.gif)")
    $iD = GetImageDim($iFile)
    If @error Then Exit

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

    $iW = $iD[0]
    $iH = $iD[1]

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

    $base_w = 150
    $base_h = 150

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

    $hGUI_w = 320
    $hGUI_h = 150
    $button_w = 100
    $hGUI = GUICreate("Bild Proportional Anzeiger von UEZ 2010", $hGUI_w, $hGUI_h) ;Titel klingt ja schreg
    $button = GUICtrlCreateButton("Exit", $base_w + ($hGUI_w - $base_w - $button_w ) / 2, $hGUI_h / 2 - 12, $button_w)

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

    If $iW < $base_w And $iH < $base_h Then
    $w = $base_w / 2 - $iW / 2
    $h = $base_h / 2 - $iH / 2
    GUICtrlCreatePic($iFile, $base_w / 2 - $iW / 2, $base_h / 2 - $iH / 2, $iW, $iH)
    Else
    If $iW > $iH Then
    $f = $iW / $base_w
    $w = $iW / $f
    $h = $ih / $f
    Else
    $f = $iH / $base_h
    $w = $iW / $f
    $h = $ih / $f
    EndIf
    GUICtrlCreatePic($iFile, $base_w / 2 - $w / 2, $base_h / 2 - $h / 2, $w, $h)
    EndIf

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

    $g = GUICtrlCreateGraphic(0, 0, $base_w, $base_h)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xc0c0ff, 0xc0c0ff)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 0, 0, $base_w, $base_h)

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

    GUISetState()

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

    Do
    Switch GUIGetMsg()
    Case -3, $button
    GUIDelete($hGUI)
    Exit
    EndSwitch
    Until False

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

    Func GetImageDim($file) ;code by Melba23 - modified by UEZ
    Local $sFile = StringRegExp($file, "(?i).*\\(.*)", 3)
    If Not IsArray($sFile) Or @error Then Return SetError(1, 0, 0)
    Local $sPath = StringRegExp($file, "(?i)(.*)\\.+", 3)
    If Not IsArray($sFile) Or @error Then Return SetError(1, 0, 0)
    Local $sDimensions = ""
    Local $oShellApp = ObjCreate("shell.application")
    If IsObj($oShellApp) Then
    Local $oDir = $oShellApp.NameSpace($sPath[0])
    If IsObj($oDir) Then
    Local $oFile = $oDir.Parsename($sFile[0])
    If IsObj($oFile) Then
    If @OSBuild > 6000 Then
    $sDimensions = $oDir.GetDetailsOf($oFile, 31)
    ElseIf @OSVersion = "WIN_XP" Then
    $sDimensions = $oDir.GetDetailsOf($oFile, 26)
    EndIf
    EndIf
    EndIf
    EndIf
    If $sDimensions = "" Then Return SetError(1, 0, 0) ;"Object creation failed"
    Local $aDimensions = StringRegExp($sDimensions, "(?i)[\d]*x*[\d]", 3)
    If Not IsArray($aDimensions) Then Return SetError(1, 0, 0) ;"Cannot get image resolution!"
    Return SetError(0, 0, $aDimensions)
    EndFunc

    [/autoit]

    Einige PNGs bzw. BMPs werden leider mit GUICtrlCreatePic() überhaupt nicht bzw. falsch angezeigt!

    Da ich mich nicht so mit den Styles auskenne, kann es sein, dass man den Code mit Styles verkürzen kann...

    Zitat


    ich hab ein gui, bei dem des Picture Control 150x150 groß ist.. in diesem control soll ein bild (beispielsweiße 1500x3000) proportional angezeit (es wird also auf 150x300 runterskaliert..)

    Du meinst hier doch bestimmt 75x150 oder?

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

    2 Mal editiert, zuletzt von UEZ (5. November 2010 um 23:53)

  • Zitat

    Du meinst hier doch bestimmt 75x150 oder?

    Richtig.. mein fehler ;)
    ok, ich werde es mal probieren.. ich /EDIT es rein, wenn es geht (oder ned) :P

    //EDIT:

    DANKE, das war genau das was ich gesucht habe..

    Einmal editiert, zuletzt von ErrorKid (6. November 2010 um 04:05)