Page 1 of 4
To save an image
Posted: Thu Oct 22, 2015 12:59 pm
by Enrico Maria Giordano
As I understood,
GDIP_IMAGEFROMFILE( cFile, .T. )
can now be used to load an image without FREEIMAGE.DLL. Is there something similar to SAVE an image?
EMG
Re: To save an image
Posted: Thu Oct 22, 2015 4:07 pm
by Antonio Linares
Enrico,
Manuel (Mastintin) is our GDI master. Lets see what he can tell us.
Re: To save an image
Posted: Thu Oct 22, 2015 4:56 pm
by mastintin
GDIP_IMAGEFROMFILE( cFile, .T. ) return classic hbitmap
Seria posible no usar freeimage.dll en la mayoria de los formatos imagenes comunes .
Funciona correcto con jpg, gif,tif,png, bmp , ico
Mas facil es unsar la clase creada a tal efecto y que se encuentra en c:\fwh\sources\tgdiplus.prg ...
Para grabar una imagen seria lago asi ...
Code: Select all | Expand
local cImage := "image.bmp"
local
local oGdi := GDIBmp():new( cImage )
oGdi:save( "imagenfinal.png")
oGdi:end()
Re: To save an image
Posted: Thu Oct 22, 2015 5:16 pm
by Enrico Maria Giordano
Thank you. I'm going to experiment with it.
EMG
Re: To save an image
Posted: Thu Oct 22, 2015 8:28 pm
by Enrico Maria Giordano
Ok, it's working, thank you.
EMG
Re: To save an image
Posted: Fri Oct 23, 2015 11:06 am
by Enrico Maria Giordano
These are a couple of functions I wrote:
Code: Select all | Expand
REQUEST GDIBMP
FUNCTION LOADIMG( cFile )
IF !FILE( cFile )
RETURN 0
ENDIF
RETURN GDIP_IMAGEFROMFILE( cFile, .T. )
FUNCTION SAVEIMG( cSrcFile, cDstFile )
LOCAL aExt := { "BMP", "JPG", "GIF", "TIF", "PNG" }
LOCAL aIds := { "{557CF400-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF401-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF402-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF405-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF406-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF403-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF404-1A04-11D3-9A73-0000F81EF32E}",;
"{557CF407-1A04-11D3-9A73-0000F81EF32E}" }
LOCAL cExt := CFILEEXT( cDstFile )
LOCAL nExt := ASCAN( aExt, cExt )
LOCAL cId := aIds[ nExt ]
LOCAL hImg := GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )
IF hImg = 0 THEN RETURN .F.
GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
DELETEOBJECT( hImg )
RETURN .T.
EMG
Re: To save an image
Posted: Fri Oct 23, 2015 12:57 pm
by mastintin
Enrico Maria Giordano wrote:These are a couple of functions I wrote:
[code=fw]
GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
EMG
Enrico, GDIPLUSIMAGESAVE function transform asitowide in your code ... is not necessary ansitowide functions
std::string str = hb_parc(2) ;
std::wstring wstr (str.begin(), str.end());
LPWSTR file = (LPWSTR) wstr.c_str();

Re: To save an image
Posted: Fri Oct 23, 2015 1:00 pm
by Enrico Maria Giordano
I've already tried: it doesn't work without ANSITOWIDE().
EMG
Re: To save an image
Posted: Sat Nov 07, 2015 1:38 pm
by Enrico Maria Giordano
[quote="Enrico Maria Giordano"
Code: Select all | Expand
LOCAL hImg := GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )
IF hImg = 0 THEN RETURN .F.
GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
DELETEOBJECT( hImg )[/quote]
Do I have to use
instead to release the image, right? Can you confirm this?
EMG
Re: To save an image [Solved]
Posted: Sat Nov 07, 2015 2:28 pm
by mastintin
Enrico Maria Giordano wrote:[quote="Enrico Maria Giordano"
Code: Select all | Expand
LOCAL hImg := GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )
IF hImg = 0 THEN RETURN .F.
GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
DELETEOBJECT( hImg )[/quote]
Do I have to use
instead to release the image, right? Can you confirm this?
EMG
Yes. Enrico use
GDIP_DELETEIMAGE( hImg ) // release pointer to gdi+ image object
instead
DELETEOBJECT( hImg ) // release pointer to "classic" image object
Re: To save an image [Solved]
Posted: Sat Nov 07, 2015 2:32 pm
by Enrico Maria Giordano
Thank you. Do you have any news for the quality of saved GIF?
Sample:
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL cSrcImage := "c:\fwh\bitmaps\magic.bmp"
LOCAL cDstImage := "magic.gif"
LOCAL oGdi := GDIBmp():New( cSrcImage )
oGdi:Save( cDstImage )
oGdi:End()
RETURN NIL
EMG
Re: To save an image [Solved]
Posted: Sat Nov 07, 2015 2:45 pm
by mastintin
Enrico . No more news.
to solve the problem, we first have to develop code for octree algorithm and my c ++ does not go that far. I have c ++ code that is done but do not get removed compile errors.
However, the GIF format is licensed for use and is overwhelmed by png or tif.
If anyone is encouraged... your code is this ....
https://www.dropbox.com/s/3syub4enpg5lx ... r.cpp?dl=0Cheers
Re: To save an image [Solved]
Posted: Sat Nov 07, 2015 2:54 pm
by Enrico Maria Giordano
Do you have QColorQuantizer.h?
EMG
Re: To save an image [Solved]
Posted: Sat Nov 07, 2015 4:31 pm
by mastintin
Re: To save an image [Solved]
Posted: Sat Nov 07, 2015 4:35 pm
by Enrico Maria Giordano
Error 404 (Page not found).

EMG