Hello,
How can I use Freeimage library with HMG 3.0.35 ? I found there is a library hmg\harbour\lib\libhbfimage.a
But, when I use this library, got some undefined functions errors during compilation and linking.
I need it to store images to tables, after reducing the size of image. Without reducing the image size, table size is increasing very much.
Thanks in advance.
Freeimage
Moderator: Rathinagiri
Re: Freeimage
Yes you can use it but .... it seems like not all Freeimage functions are supported via the libhbfimage.a or the functions call maybe different to the Freeimage documentation.
- you should include freeimage.ch
- you should include this code at the beginning of your program
- and a *.hbc file is recommended (assuming you have a subdir called lib under your program dir containing the file libfreeimage.a)
- you should include freeimage.ch
- you should include this code at the beginning of your program
Code: Select all
IF !FILE('FreeImage.Dll')
MsgAlert("Can't found the FreeImage.Dll")
Return Nil
ENDIF
fi_Initialise()
Code: Select all
incpaths=
libpaths=lib
libs=FreeImage
Re: Freeimage
Thanks a lot Ricci. I created following function as follows:
I have some problem with it.
Ok I shall wait for HMG.4. It will be the software tool of my dream
Code: Select all
#define STD_WIDTH 123
#define STD_HEIGHT 123
// Following function is used to reduce the image size
// This will be useful for storing large image file into memo field
// This will reduce table size to a great extent :-) Sudip
Function ImageCompress(cFile)
local isJpg := .f., isBmp := .f., isGif := .f.
local cStr, im, rescale, mHeight, mWidth
do case
case upper(right(cFile, 3)) == "JPG"
isJpg := .t.
case upper(right(cFile, 3)) == "BMP"
isBmp := .t.
case upper(right(cFile, 3)) == "GIF"
isGif := .t.
otherwise
return ""
endcase
cStr := MemoRead(cFile)
im := FI_LoadFromMem( if(isJpg, FIF_JPEG, if(isBmp, FIF_BMP, FIF_GIF)), cStr, JPEG_DEFAULT )
mWidth := fi_GetWidth( im )
mHeight := fi_GetHeight( im )
if mWidth > STD_HEIGHT
rescale := fi_Rescale( im, mWidth * (STD_HEIGHT / mHeight), STD_HEIGHT, FILTER_BICUBIC )
cTemp := TempFileName()
fi_Save( FIF_JPEG, rescale, cTemp, JPEG_DEFAULT )
cStr := MemoRead(cTemp)
fi_unload( rescale )
filedelete( cTemp )
endif
fi_Unload( im )
return (cStr)
FUNCTION TempFileName()
LOCAL nFileHandle
LOCAL cFileName := ""
nFileHandle := HB_FTempCreate( ,,, @cFileName )
IF nFileHandle > 0
FClose( nFileHandle )
ENDIF
RETURN cFileName
Ok I shall wait for HMG.4. It will be the software tool of my dream
With best regards,
Sudip
Sudip