Jump to content
Sign in to follow this  
xzaz

Show photo as wide as posible

Recommended Posts

Case $volgende
                GuiSwitch($ShowGUI,$volgende)
                GUICtrlDelete($picview)
                GuiCtrlSetData($label,$FileList[$i])
                $Filesize = _ImageGetSize($standardmap&"\"&$FileList[$i])
                ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
                if $Filesize[0] > $_ShowGUIH AND $Filesize[1] > $_ShowGUIW Then
                $picview = GuiCtrlCreatePic($standardmap&"\"&$FileList[$i],($_ShowGUIW - ($Filesize[0] / 2))/2,($_ShowGUIH - ($Filesize[1] /2))/2,$Filesize[0] / 2,$Filesize[1] / 2)
                Else
                $picview = GuiCtrlCreatePic($standardmap&"\"&$FileList[$i],($_ShowGUIW - $Filesize[0])/2,($_ShowGUIH - $Filesize[1])/2,$Filesize[0],$Filesize[1])
                Endif
                $i = $i +1

Well here you see that when there is a photo bigger then the screen w/h it just makes him half size and put it on the screen. Now when there are some bigger photo's, how can i make sure the fill up the FULL screen as much as posible?

$_ShowGUIH = res H

$_ShowGUIW = res W

Edited by xzaz

Share this post


Link to post
Share on other sites

you need to find out which of the two (height or width), is the one that is going to fill the screen... find the difference in size, convert to ratio, or percentage, and apply that ratio/percentage to the other axis as well... that would be proper fullscreen viewing without morphing the picture

Share this post


Link to post
Share on other sites

sorry this took so long - had to learn it

do the following

navigate to: http://www.microsoft.com/downloads/details...;DisplayLang=en

download: WIAAutSDK.zip -install to C:\ or what ever u use

open command prompt

type: CD C:\

Press Enter

type: regsvr32 wiaaut.dll

Wait for ok message then run the follow code against on of your GIFs or modify if you are using another pic format

$oImage = ObjCreate("WIA.ImageFile")
$s_Path = FileOpenDialog("Select Gif Image", @ScriptDir, "Gif Images (*.gif)")
$oImage.LoadFile($s_Path)
$HorizontalRes = $oImage.HorizontalResolution
$VerticalRes = $oImage.verticalResolution
MsgBox(0, "Horizontal", $HorizontalRes)
MsgBox(0, "Vertical", $VerticalRes)oÝ÷ Ú붬ëa¡Ûhb,¨º¼"vØZØ^a¢{ayùr¢¸ v¥¦-º¹

I havent checked this last if stuff btw -just an example

Edited by Hatcheda

Share this post


Link to post
Share on other sites

make sure the one you used is

$HorizontalRes = $oImage.HorizontalResolution
$VerticalRes = $oImage.verticalResolution

so they would be the same

Ill build you a demo I guess so that you can see it work (and me too) :)

Edited by Hatcheda

Share this post


Link to post
Share on other sites

Wow tnx for your support so far appreciate that. I got this but still got the 300,300 numbers, i have to study the code more to understand how he comes up with 300,300:

$oImage = ObjCreate("WIA.ImageFile")
$s_Path = FileOpenDialog("Select Gif Image", @ScriptDir, "Gif Images (*.jpg)")
$oImage.LoadFile($s_Path)


$HorizontalRes = $oImage.HorizontalResolution
$VerticalRes = $oImage.verticalResolution

If $HorizontalRes > @DesktopWidth then
$HorizontalRes = ($HorizontalRes - @DesktopWidth)
$HorizontalResPerc = ($HorizontalRes - @DesktopWidth)/$HorizontalRes
$VerticalRes = $VerticalRes*$HorizontalResPerc
Else
    If $VerticalRes > @DesktopHeight then
    $VerticalRes = ($VerticalRes - @DesktopHeight)
    $VerticalResPerc = ($VerticalRes - @DesktopHeight)/$VerticalRes
    $HorizontalRes = $HorizontalRes*$VerticalResPerc
    EndIf
Endif
MsgBox(0, "Horizontal", $HorizontalRes)
MsgBox(0, "Vertical", $VerticalRes)

Share this post


Link to post
Share on other sites

Ha ha ha -I was giving you the pixels per square inch :)

$HorizontalRes = $oImage.Width

$VerticalRes = $oImage.Height

lol i saw it just wanted to edit my post:

$oImage = ObjCreate("WIA.ImageFile")
$s_Path = FileOpenDialog("Select Gif Image", @ScriptDir, "Gif Images (*.jpg)")
$oImage.LoadFile($s_Path)


$HorizontalRes = $oImage.HorizontalResolution
$VerticalRes = $oImage.verticalResolution
MsgBox(0,"",$HorizontalRes)
MsgBox(0,"",$verticalRes)
If $HorizontalRes > @DesktopWidth then
$HorizontalRes = ($HorizontalRes - @DesktopWidth)
$HorizontalResPerc = ($HorizontalRes - @DesktopWidth)/$HorizontalRes
$VerticalRes = $VerticalRes*$HorizontalResPerc
Else
    If $VerticalRes > @DesktopHeight then
    $VerticalRes = ($VerticalRes - @DesktopHeight)
    $VerticalResPerc = ($VerticalRes - @DesktopHeight)/$VerticalRes
    $HorizontalRes = $HorizontalRes*$VerticalResPerc
    EndIf
Endif
MsgBox(0, "Horizontal", $HorizontalRes)
MsgBox(0, "Vertical", $VerticalRes)

First 2 msgboxes where already 300,300 XD

Share this post


Link to post
Share on other sites

ok here ya go. kindly disregard the previouse if post. it was full of errors. working example below.

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_Custom_Exit")
$GUI = GUICreate("Unimportant GUI", @DesktopWidth, @DesktopHeight, Default, Default, $WS_POPUPWINDOW)

$oImage = ObjCreate("WIA.ImageFile")
$s_Path = FileOpenDialog("Select Gif Image", @ScriptDir, "Gif Images (*.gif)")
$oImage.LoadFile($s_Path)
$HorizontalRes = $oImage.Width
$VerticalRes = $oImage.Height 


If $oImage.Width > @DesktopWidth then 
$HorizontalRes = @DesktopWidth
$HorizontalResPerc = ($oImage.Width - @DesktopWidth)/$oImage.Width
$VerticalRes = $oImage.Height*$HorizontalResPerc
ElseIf $oImage.Height > @DesktopHeight then 
$VerticalRes =  @DesktopHeight
$VerticalResPerc = ($oImage.Height - @DesktopHeight)/$oImage.Height
$HorizontalRes = $oImage.Width*$VerticalResPerc
EndIf

;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
$Pic = GUICtrlCreatePic($s_Path, Default, Default, $HorizontalRes, $VerticalRes)
GUISetState(@SW_SHOW, $GUI)

; ============================================================================
; Main Loop
; ============================================================================

While 1
    Sleep(10)
WEnd

; ============================================================================
; Functions
; ============================================================================
Func _Custom_Exit()
    Exit
EndFunc   ;==>_Custom_Exit

tested on 1920 X 1080 -horizontal where pic is too big -working

Trying to fix height adjustment by % of horizontal adjustment

Edited by Hatcheda

Share this post


Link to post
Share on other sites

ok, fixed

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_Custom_Exit")
$GUI = GUICreate("Unimportant GUI", @DesktopWidth, @DesktopHeight, Default, Default, $WS_POPUPWINDOW)

$oImage = ObjCreate("WIA.ImageFile")
$s_Path = FileOpenDialog("Select Gif Image", @ScriptDir, "Gif Images (*.jpg)")
$oImage.LoadFile($s_Path)
$HorizontalRes = $oImage.Width
$VerticalRes = $oImage.Height 

If $oImage.Width > @DesktopWidth then 
$HorizontalRes = @DesktopWidth
$HorizontalResPerc = (1 - (($oImage.Width - @DesktopWidth)/$oImage.Width))
$VerticalRes = $oImage.Height*($HorizontalResPerc)
ElseIf $oImage.Height > @DesktopHeight then 
$VerticalRes =  @DesktopHeight
$VerticalResPerc = (1 - (($oImage.Height - @DesktopHeight)/$oImage.Height))
$HorizontalRes = $oImage.Width*($VerticalResPerc)
EndIf

;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
$Pic = GUICtrlCreatePic($s_Path, Default, Default, $HorizontalRes, $VerticalRes)
GUISetState(@SW_SHOW, $GUI)

; ============================================================================
; Main Loop
; ============================================================================

While 1
    Sleep(10)
WEnd

; ============================================================================
; Functions
; ============================================================================
Func _Custom_Exit()
    Exit
EndFunc   ;==>_Custom_Exit

If you have any questions, please let me know.

Share this post


Link to post
Share on other sites

your welcome. (wondering if you would have any issue where h <> w but both are bigger than @dw and @dh) it seems like it would run through both if statements and only bring one of them in. May need some work (in theory) -if H = W then the second if would fix it for wide or square monitors.

If either smaller than @d~ then one or the other if would fix it. Just a question of both bigger and not equal :)

Share this post


Link to post
Share on other sites

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         Eise van der Spoel

 Script Function:
    Foto's bekijken voor de kerk

#ce ----------------------------------------------------------------------------
#include <GUIConstants.au3>
#include <File.au3>
#Include <Array.au3>
#include <image_get_size.au3>
#Include <Misc.au3>

$oImage = ObjCreate("WIA.ImageFile")

Global $Filter = "*.jpg"
Global $ShowGUI,$MainGUI,$label,$picview,$color,$countfotosgui,$photo_folder,$fotofoldergui
Global $Title = "Foto Show v1.0"
Global $FileList
Global $i = 1
Global $_fotoW = 535
Global $_fotoH = 535
Global $_ShowGUIW = @DesktopWidth
Global $_ShowGUIH = @DesktopHeight
_MainGUI()



Func _MainGUI()
    Local $_MainGUIW = 415
    Local $_MainGUIH = 50
    $MainGUI = GuiCreate($Title,$_MainGUIW,$_MainGUIH)
    $map = GuiCtrlCreateButton("Map",1,2,40)
    $start = GuiCtrlCreateButton("Start",45,2,40)
    $stop = GuiCtrlCreateButtoN("Stop",90,2,40)
    $vorige = GuiCtrlCreateButton("<",145,2,20)
    $volgende = GuiCtrlCreateButton(">",170,2,20)
    $pauze = GuiCtrlCreateButton("||",195,2,20)
    $sluiten = GuiCtrlCreateButton("Sluiten",$_MainGUIW - 45,2,40)
    $color = GuictrlCreateButton("BG",$_MainGUIW - 90,2,40)
    
    GuiCtrlCreatelabel("Foto map:",1,35)
    $fotofoldergui = GuiCtrLCreatelabel("",55,35,200)
    GuiCtrlCreateLabel("Foto:",170,35,100)
    $countfotosgui = GuiCtrlCreateLabel("<>",210,35,30)
    GUICtrlSetState($stop,$GUI_DISABLE)
    GUiCtrlSetState($volgende,$GUI_DISABLE)
    GUiCtrlSetState($vorige,$GUI_DISABLE)
    GuiCtrlSetState($pauze,$GUI_DISABLE)
    GuiSetstate()
    
    _LoadFotos()
    While 1
        $msg = GuiGetMsg()
        Switch $msg
        Case $map
            _LoadFotos()
        Case $start
            if WinExists("fotoshow") Then
                ;
            Else
                GUICtrlSetState($stop,$GUI_ENABLE)
                GUiCtrlSetState($volgende,$GUI_ENABLE)
                GUiCtrlSetState($vorige,$GUI_ENABLE)
                GuiCtrlSetState($pauze,$GUI_ENABLE)
            _Openshow()
            Endif
            WinActivate($Title)
        Case $stop
            GUIDelete($ShowGUI)
            GUICtrlSetState($stop,$GUI_DISABLE)
    GUiCtrlSetState($volgende,$GUI_DISABLE)
    GUiCtrlSetState($vorige,$GUI_DISABLE)
    GuiCtrlSetState($pauze,$GUI_DISABLE)
        Case $GUI_EVENT_CLOSE,$sluiten
            Exit 0
        Case $volgende
                if $i = $FileList[0] +1 Then
                    MsgBox(0,"Bericht","Geen volgende foto")
                Else
                GuiCtrlSetData($countfotosgui,$i&"/"&$FileList[0])
                GuiSwitch($ShowGUI,$volgende)
                GuiCtrlSetData($label,$FileList[$i])
                ;$Filesize = _ImageGetSize($photo_folder&"\"&$FileList[$i])
                ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
                $s_Path = $photo_folder&"\"&$FileList[$i]
                
                    $oImage.LoadFile($s_Path)
                    $HorizontalRes = $oImage.Width
                    $VerticalRes = $oImage.Height

                    If $oImage.Width > @DesktopWidth then
                    $HorizontalRes = @DesktopWidth
                    $HorizontalResPerc = (1 - (($oImage.Width - @DesktopWidth)/$oImage.Width))
                    $VerticalRes = $oImage.Height*($HorizontalResPerc)
                    ElseIf $oImage.Height > @DesktopHeight then
                    $VerticalRes =  @DesktopHeight
                    $VerticalResPerc = (1 - (($oImage.Height - @DesktopHeight)/$oImage.Height))
                    $HorizontalRes = $oImage.Width*($VerticalResPerc)
                    EndIf
                
                    GUICtrlDelete($picview)
                    ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
                    $picview = GuiCtrlCreatePic($photo_folder&"\"&$FileList[$i],Default,Default,$HorizontalRes,$VerticalRes)
                $i = $i +1
                Endif
            Case $vorige
                if $i = 1 Then
                    MSgBox(0,"Bericht","Geen vorige foto")
                Else
                GuiCtrlSetData($countfotosgui,$i&"/"&$FileList[0])
                GuiSwitch($ShowGUI,$volgende)
                GuiCtrlSetData($label,$FileList[$i])
                $Filesize = _ImageGetSize($photo_folder&"\"&$FileList[$i])
                ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
                    if $Filesize[0] > $_ShowGUIH AND $Filesize[1] > $_ShowGUIW Then
                    GUICtrlDelete($picview)
                    $picview = GuiCtrlCreatePic($photo_folder&"\"&$FileList[$i],($_ShowGUIW - ($Filesize[0] / 2))/2,($_ShowGUIH - ($Filesize[1] /2))/2,$Filesize[0] / 2,$Filesize[1] / 2)
                    Else
                    GUICtrlDelete($picview)
                    $picview = GuiCtrlCreatePic($photo_folder&"\"&$FileList[$i],($_ShowGUIW - $Filesize[0])/2,($_ShowGUIH - $Filesize[1])/2,$Filesize[0],$Filesize[1])
                    Endif
                $i = $i -1
                Endif
            Case $color
                $color = _ChooseColor(2)
                GUISetBkColor ($color,$ShowGUI)
        EndSwitch
    WEnd
   
   
Endfunc

Func _Openshow()
    
    $ShowGUI = GuiCreate("fotoshow",$_ShowGUIW ,$_ShowGUIH,0,0,$WS_POPUP)
    $picview = GUICtrlCreatePic("logogkv.jpg",($_ShowGUIW - $_fotoW)/2,($_ShowGUIH - $_fotoH)/2,$_fotoW,$_fotoH)
    $label = GuiCtrlCreateLABEL("",0,0,100)
    GuiSetBKColor(0xFFFFFF)
    GuiSetState()
EndFunc

Func _LoadFotos()
            $i = 1
            $photo_folder = FileSelectFolder("Selecteer de map waarin de foto's zich bevinden", "", 1)  
            $FileList=_FileListToArray($photo_folder,$Filter)
            If @Error=1 Then
                MsgBox (0,"","Geen bestanden en/of map gekozen.")
                Exit 0
            Endif
            GuiCtrlSetData($fotofoldergui,$photo_folder)
            GuiCtrlSetData($countfotosgui,"0/"&$FileList[0])
Endfunc

Got this so far, but he cant adjust the picture right, any suggestion?

Share this post


Link to post
Share on other sites

*Again with out reading, you could just add the pic section into a function. Each time you run the function you use guictrldelete($pic) then read it with the new pic. if not what you mean, i will read and translate :)

as it stands, I dont not have all the includes required to run your script.

but by the condition of it I believe you should be able to add a function to delete and rebuild $pic

good luck with it!

Edited by Hatcheda

Share this post


Link to post
Share on other sites

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.10.0
 Author:         Eise van der Spoel,http://www.autoitscript.com/forum/index.php?showtopic=59495&st=0

 Script Function:
    Foto's bekijken voor de kerk

#ce ----------------------------------------------------------------------------
#include <GUIConstants.au3>
#include <File.au3>
#Include <Array.au3>
#Include <Misc.au3>

$oImage = ObjCreate("WIA.ImageFile")

Global $Filter = "*.jpg"
Global $ShowGUI,$MainGUI,$label,$picview,$color,$countfotosgui,$photo_folder,$fotofoldergui,$loop
Global $Title = "Foto Show v1.0"
Global $FileList
Global $i = 1
Global $_fotoW = 535
Global $_fotoH = 535
Global $_ShowGUIW = @DesktopWidth
Global $_ShowGUIH = @DesktopHeight
Global $stoppen = 0
_MainGUI()



Func _MainGUI()
    Local $_MainGUIW = 415
    Local $_MainGUIH = 50
    $MainGUI = GuiCreate($Title,$_MainGUIW,$_MainGUIH)
    $map = GuiCtrlCreateButton("Map",1,2,40)
    $start = GuiCtrlCreateButton("Start",45,2,40)
    $stop = GuiCtrlCreateButtoN("Stop",90,2,40)
    $vorige = GuiCtrlCreateButton("<",145,2,20)
    $volgende = GuiCtrlCreateButton(">",170,2,20)
    $pauze = GuiCtrlCreateButton("||",195,2,20)
    $sluiten = GuiCtrlCreateButton("Sluiten",$_MainGUIW - 45,2,40)
    $color = GuictrlCreateButton("BG",$_MainGUIW - 90,2,40)
    $loop = GuiCtrlCreateButton("Loop",$_MainGUIW - 135,2,40)
    
    GuiCtrlCreatelabel("Foto map:",1,35)
    $fotofoldergui = GuiCtrLCreatelabel("",55,35,200)
    GuiCtrlCreateLabel("Foto:",170,35,100)
    $countfotosgui = GuiCtrlCreateLabel("<>",210,35,30)
    GUICtrlSetState($stop,$GUI_DISABLE)
    GUiCtrlSetState($volgende,$GUI_DISABLE)
    GUiCtrlSetState($vorige,$GUI_DISABLE)
    GuiCtrlSetState($pauze,$GUI_DISABLE)
    GuiCtrlSetState($loop,$GUI_DISABLE)
    GuiSetstate()
    
    _LoadFotos()
    While 1
        $msg = GuiGetMsg()
        Switch $msg
        Case $map
            _LoadFotos()
        Case $start
            if WinExists("fotoshow") Then
                ;
            Else
                GUICtrlSetState($stop,$GUI_ENABLE)
                GUiCtrlSetState($volgende,$GUI_ENABLE)
                GUiCtrlSetState($vorige,$GUI_ENABLE)
                GuiCtrlSetState($pauze,$GUI_ENABLE)
                GuiCtrlSetState($loop,$GUI_ENABLE)
            _Openshow()
            Endif
            WinActivate($Title)
        Case $stop
            GUIDelete($ShowGUI)
            GUICtrlSetState($stop,$GUI_DISABLE)
    GUiCtrlSetState($volgende,$GUI_DISABLE)
    GUiCtrlSetState($vorige,$GUI_DISABLE)
    GuiCtrlSetState($pauze,$GUI_DISABLE)
        GuiCtrlSetState($loop,$GUI_DISABLE)

        Case $GUI_EVENT_CLOSE,$sluiten
            Exit 0
        Case $volgende
                if $i = $FileList[0] +1 Then
                    MsgBox(0,"Bericht","Geen volgende foto")
                Else
                photofunc()
                $i = $i +1
                Endif
            Case $vorige
                if $i = 1 Then
                    MSgBox(0,"Bericht","Geen vorige foto")
                Else
                photofunc()
                $i = $i -1
                Endif
            Case $color
                $color = _ChooseColor(2)
                GUISetBkColor ($color,$ShowGUI)
            Case $stop
                $stoppen = 1
            Case $loop
                loopfoto()
        EndSwitch
    WEnd
   
   
Endfunc

Func _Openshow()
    
    $ShowGUI = GuiCreate("fotoshow",$_ShowGUIW ,$_ShowGUIH,0,0,$WS_POPUP)
    $picview = GUICtrlCreatePic("logogkv.jpg",($_ShowGUIW - $_fotoW)/2,($_ShowGUIH - $_fotoH)/2,$_fotoW,$_fotoH)
    $label = GuiCtrlCreateLABEL("",0,0,100)
    GuiSetBKColor(0xFFFFFF)
    GuiSetState()
EndFunc

Func _LoadFotos()
            $i = 1
            $photo_folder = FileSelectFolder("Selecteer de map waarin de foto's zich bevinden", "", 1)  
            $FileList=_FileListToArray($photo_folder,$Filter)
            If @Error=1 Then
                MsgBox (0,"","Geen bestanden en/of map gekozen.")
                Exit 0
            Endif
            GuiCtrlSetData($fotofoldergui,$photo_folder)
            GuiCtrlSetData($countfotosgui,"0/"&$FileList[0])
Endfunc

Func loopfoto()
While 1
    $Sleep = Sleep(3*1000)
    if $i = $FileList[0] +1 Then
                    MsgBox(0,"Bericht","Geen volgende foto")
                    $stoppen = 1
    Else
                    photofunc()
                    $i = $i +1
    Endif
    if $stoppen = 1 Then Exitloop
Wend
EndFunc
Func photofunc()
    GuiCtrlSetData($countfotosgui,$i&"/"&$FileList[0])
                GuiSwitch($ShowGUI,$loop)
                GuiCtrlSetData($label,$FileList[$i])
                ;$Filesize = _ImageGetSize($photo_folder&"\"&$FileList[$i])
                ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
                $s_Path = $photo_folder&"\"&$FileList[$i]
                
                    $oImage.LoadFile($s_Path)
                    $HorizontalRes = $oImage.Width
                    $VerticalRes = $oImage.Height

                    If $oImage.Width > @DesktopWidth then
                    $HorizontalRes = @DesktopWidth
                    $HorizontalResPerc = (1 - (($oImage.Width - @DesktopWidth)/$oImage.Width))
                    $VerticalRes = $oImage.Height*($HorizontalResPerc)
                    ElseIf $oImage.Height > @DesktopHeight then
                    $VerticalRes =  @DesktopHeight
                    $VerticalResPerc = (1 - (($oImage.Height - @DesktopHeight)/$oImage.Height))
                    $HorizontalRes = $oImage.Width*($VerticalResPerc)
                    EndIf
                    
                    GUICtrlDelete($picview)
                    ;GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )
                    $picview = GuiCtrlCreatePic($photo_folder&"\"&$FileList[$i],Default,Default,$HorizontalRes,$VerticalRes)
Endfunc

Well something like this :), I have to edit te code, its a little bit mess right now ^_^

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...