To save an image
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
To save an image
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
GDIP_IMAGEFROMFILE( cFile, .T. )
can now be used to load an image without FREEIMAGE.DLL. Is there something similar to SAVE an image?
EMG
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: To save an image
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 ...
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()
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: To save an image
These are a couple of functions I wrote:
EMG
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
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();
![Very Happy :D](./images/smilies/icon_biggrin.gif)
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: To save an image
[quote="Enrico Maria Giordano"
Do I have to use
instead to release the image, right? Can you confirm this?
EMG
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
Code: Select all | Expand
GDIP_DELETEIMAGE( hImg )
instead to release the image, right? Can you confirm this?
EMG
Re: To save an image [Solved]
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 useCode: Select all | Expand
GDIP_DELETEIMAGE( hImg )
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
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
Re: To save an image [Solved]
Thank you. Do you have any news for the quality of saved GIF?
Sample:
EMG
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]
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=0
Cheers
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=0
Cheers
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact:
- Enrico Maria Giordano
- Posts: 8753
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 4 times
- Contact: