FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to use < SaveImage > to save a image RESIZED ? (solved)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
How to use < SaveImage > to save a image RESIZED ? (solved)
Posted: Fri Apr 25, 2014 03:45 PM
Hello,

is it possible, saving a image RESIZED like using :
oExpImage:SaveImage( cFilename, nExport )
or maybe another solution ( any working sample ) ?

Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: How to use < SaveImage > to save a image RESIZED ?
Posted: Fri Apr 25, 2014 04:56 PM

* New: function FIMakeThumbNail( cSrcFile, cDstFile, nPixel ) --> lOk thanks to
Carlos Vargas:
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to use < SaveImage > to save a image RESIZED ?
Posted: Fri Apr 25, 2014 05:36 PM
Carlos,

thank You very much for the info.
I cannot post a screenshot before monday, because of server-changes.
The problem, I have to keep the aspect ratio width and height.
It means I want to resize with a zoom-factor ( % ) or
a given width with the height calculated
or a given height with the width calculated.

FIMAKETHUMBNAIL( cSrcFile, cDstFile, nPixel )

width and height will be the same.

GOT IT WORKING !!!
Saved a image resized keeping the aspect ratio.
works with %, a given width or a given height

Code (fw): Select all Collapse
// STATIC oDrawImg, nExpResize, nExpWidth, nExpHeight, cExtension

STATIC FUNCTION SAVE_EXP()
LOCAL oExpImage, hResizeImg, cFilename, lResize := .F., nFactor := 1
LOCAL nIWidth := oDrawImg:nWidth
LOCAL nIHeight := oDrawImg:nHeight
LOCAL nWFactor := nExpWidth / nIWidth 
LOCAL nHFactor := nExpHeight / nIHeight 

nFilecount++ // filecounter

cFilename := cExppath + ALLTRIM(cDestFile) + ;
   ALLTRIM(STR(nFileCount)) + "." + cExtension

DEFINE IMAGE oExpImage FILENAME cFilename 

IF nExpResize <> 0 // given %
     nFactor := nExpResize / 100
     nIWidth := oDrawImg:nWidth * nFactor
     nIHeight := oDrawImg:nHeight * nFactor 
     lResize := .T.
ELSEIF nExpWidth > 0 // defined width ( height calculated )
     nIWidth := nExpWidth
     nIHeight := oDrawImg:nHeight  * nWFactor 
     lResize := .T.
ELSEIF nExpHeight > 0 // defined height ( width calculated )
     nIWidth := oDrawImg:nWidth * nHFactor 
     nIHeight := nExpHeight
     lResize := .T.
ENDIF
IF lResize = .F.
     MsgAlert( "NO resize-factor defined !" +CRLF + ;
                    "original size is used ", "Resize-factor" )
ENDIF

hResizeImg := ResizeImg( oDrawImg:hBitmap, nIWidth, nIHeight )
oExpImage:hBitmap := hResizeImg
oExpImage:SaveImage( cFilename, nExport )
oExpImage:End()

RETURN NIL


Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion