Code: Select all
*tab 3, in array aFotoNaam are the names of the images
nRowPaint := 450
nColumn := 10
nfotoToon := 1
FOR r = 1 TO 3
FOR k = 1 TO 5
cImage := aFotoNaam[nFotoToon]
oImgName := 'oImg' + ALLTRIM(STR(nFoto))
@ nRowPaint, nColumn IMAGE &oImgName FILENAME cImage OF oFld:aControls[ 3 ] SIZE 110, 110
nColumn := nColumn + 120
nFotoToon++
NEXT
nColumn := 10
nRowPaint := nRowPaint - 120
NEXT
@ 40, 650 BUTTON "New photo" OF oFld:aDialogs[ 3 ] ACTION RK_SelectFoto(nPlantnum) SIZE 120, 30
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( "Selecteer een foto", "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, nFotoWidth BUTTON oBtnOK PROMPT "Ok" OF oWndFoto ACTION oWndFoto:End()
ACTIVATE DIALOG oWndFoto
*and save the rescaled image in the temp folder
SaveImageFromImage( cFoto, cKopie, nFotoWidth, nFotoHeight )
*add the name to the foto array
aFotoNaam[nFoto] := cKopie
*show the new image
oImgName := 'oImg' + ALLTRIM(STR(nFoto))
* &oImgName:setImage( cKopie )
ImgSetNSImage(::oDlgChange,cKopie)
ENDIF
RETURN