I have used the new function SaveImageFromImage() and it works perfect. Here is the code I used.
- Code: Select all Expand view RUN
- 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