resizing images

resizing images

Postby plantenkennis » Tue Oct 04, 2016 8:45 pm

Hello Antonio,

I have used the new function SaveImageFromImage() and it works perfect. Here is the code I used.
Code: Select all  Expand view
FUNCTION RK_SelectFoto(nPlantnum)
*to select a picture, resize it and place it in the right folder
*28-09-2016

LOCAL oWndFoto, oBtnOK
LOCAL oFoto
LOCAL cFoto := ''
LOCAL cKopie := ''
LOCAL nMaxWidth := 1000
LOCAL nMaxHeight := 800
LOCAL nFotoWidth
LOCAL nFotoHeight
LOCAL nFactor := 0

*choose photo
cFoto := ChooseFile( "Select an photo", "jpg" )
IF LEN(ALLTRIM(cFoto)) > 0
    nFoto++
    cKopie := cPath + '/temp/' + ALLTRIM(STR(nPlantnum+nFoto)) + '.jpg'

*define a window to check the size of the photo
    DEFINE DIALOG oWndFoto TITLE "grote foto" ;
        FROM 0, 0 TO 800, 800
       
        @ 40, 10 IMAGE oFoto FILENAME cFoto OF oWndFoto SIZE 640, 480

*check the size of the photo
        nFotoWidth := oFoto:GetWidth()
        nFotoHeight := oFoto:GetHeight()

*if the photo is too wide, set the right width
        IF nFotoWidth > 1000
            nFactor := 1000 / nFotoWidth
            nFotoWidth := 1000
            nFotoHeight  := ROUND(nFotoHeight * nFactor, 0)
        ENDIF
*if the photo is still to high, set the right height
        IF nFotoHeight > 800
            nFactor := 800 / nFotoHeight
            nFotoHeight := 800
            nFotoWidth  := ROUND(nFotoWidth * nFactor, 0)
        ENDIF

*now rescale the IMAGE
        oFoto:SetSize( nFotoWidth, nFotoHeight )
                      oFoto:SetScaling( 1 )  
        oWndFoto:SetSize( nFotoWidth + 20, nFotoHeight + 40 )

        @ 10, 10 BUTTON oBtnOK PROMPT "Ok" OF oWndFoto ACTION oWndFoto:End()

    ACTIVATE DIALOG oWndFoto
   
    SaveImageFromImage( cFoto, cKopie, nFotoWidth, nFotoHeight )
   
ENDIF

RETURN

 


Thanks for this new function
Rene
Kind regards,

René Koot
plantenkennis
 
Posts: 70
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

Re: resizing images

Postby Antonio Linares » Tue Oct 04, 2016 10:52 pm

Glad to know that it is working fine

many thanks for your great feedback :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 35350
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 0 guests