To save an image

To save an image

Postby Enrico Maria Giordano » Thu Oct 22, 2015 12:59 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image

Postby Antonio Linares » Thu Oct 22, 2015 4:07 pm

Enrico,

Manuel (Mastintin) is our GDI master. Lets see what he can tell us.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: To save an image

Postby mastintin » Thu Oct 22, 2015 4:56 pm

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 view


local cImage := "image.bmp"
local
local oGdi := GDIBmp():new( cImage )
        oGdi:save( "imagenfinal.png")
       oGdi:end()
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image

Postby Enrico Maria Giordano » Thu Oct 22, 2015 5:16 pm

Thank you. I'm going to experiment with it.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image

Postby Enrico Maria Giordano » Thu Oct 22, 2015 8:28 pm

Ok, it's working, thank you.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image

Postby Enrico Maria Giordano » Fri Oct 23, 2015 11:06 am

These are a couple of functions I wrote:

Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image

Postby mastintin » Fri Oct 23, 2015 12:57 pm

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();

:D
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image

Postby Enrico Maria Giordano » Fri Oct 23, 2015 1:00 pm

I've already tried: it doesn't work without ANSITOWIDE().

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image

Postby Enrico Maria Giordano » Sat Nov 07, 2015 1:38 pm

[quote="Enrico Maria Giordano"
Code: Select all  Expand view
    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 view
GDIP_DELETEIMAGE( hImg )


instead to release the image, right? Can you confirm this?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image [Solved]

Postby mastintin » Sat Nov 07, 2015 2:28 pm

Enrico Maria Giordano wrote:[quote="Enrico Maria Giordano"
Code: Select all  Expand view
   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 view
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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image [Solved]

Postby Enrico Maria Giordano » Sat Nov 07, 2015 2:32 pm

Thank you. Do you have any news for the quality of saved GIF?

Sample:

Code: Select all  Expand view
#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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image [Solved]

Postby mastintin » Sat Nov 07, 2015 2:45 pm

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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image [Solved]

Postby Enrico Maria Giordano » Sat Nov 07, 2015 2:54 pm

Do you have QColorQuantizer.h?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: To save an image [Solved]

Postby mastintin » Sat Nov 07, 2015 4:31 pm

User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image [Solved]

Postby Enrico Maria Giordano » Sat Nov 07, 2015 4:35 pm

Error 404 (Page not found). :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 81 guests