To save an image

Re: To save an image [Solved]

Postby mastintin » Mon Nov 09, 2015 8:02 pm

your obj files send :-)
new function to save gif files...

GDIPLUSSAVEOCTREEGIF( hbmp, cNameFile )

hbmp -> pointer to gdi+ image
cNamefile-> name to save ( with extension .gif ) pass -> ansitowide( "c:\myfile.gif" )

sample :
Code: Select all  Expand view

function saveImgfile(cFile )
local ohBmp := GDIBmp():new(cFile)  
 local   cSave:= cGetfile("graba","*.*")
      cSave:= alltrim(cSave)
      if Upper(right(cSsave,3)) == "GIF"
         GDIPLUSSAVEOCTREEGIF( ohbmp:hbmp, cSave )
      else
         ohbmp:save(cSave )
      endif
      ohbmp:end()
Return nil

 


report their results in the test...
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image [Solved]

Postby Enrico Maria Giordano » Mon Nov 09, 2015 9:03 pm

With the following sample I get the same bad result. What am I missing?

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL cSrcImage := "c:\fwh\bitmaps\magic.bmp"
    LOCAL cDstImage := "magic.gif"

    ? SAVEIMG( cSrcImage, cDstImage )

    RETURN NIL


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 := UPPER( CFILEEXT( cDstFile ) )

    LOCAL nExt := ASCAN( aExt, cExt )

    LOCAL cId := aIds[ nExt ]

    LOCAL hImg

    IF !FILE( cSrcFile )
        RETURN .F.
    ENDIF

    hImg = GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )

    IF cExt != "GIF"
        GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
    ELSE
        GDIPLUSSAVEOCTREEGIF( hImg, ANSITOWIDE( cDstFile ) )
    ENDIF

    GDIP_DELETEIMAGE( 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 [Solved]

Postby mastintin » Mon Nov 09, 2015 10:35 pm

Enrico . The problem is with magic.bmp . Is bmp PixelFormat8bppIndexed ( not normal bmp ).
I send a new obj file ...
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image [Solved]

Postby Enrico Maria Giordano » Mon Nov 09, 2015 10:41 pm

Seems to work perfect, 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 [Solved]

Postby Enrico Maria Giordano » Sat Dec 05, 2015 2:18 pm

With the new FWH 15.10 my sample doesn't link anymore:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL cSrcImage := "c:\fwh\bitmaps\magic.bmp"
    LOCAL cDstImage := "magic.gif"

    ? SAVEIMG( cSrcImage, cDstImage )

    RETURN NIL


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 := UPPER( CFILEEXT( cDstFile ) )

    LOCAL nExt := ASCAN( aExt, cExt )

    LOCAL cId := aIds[ nExt ]

    LOCAL hImg

    IF !FILE( cSrcFile )
        RETURN .F.
    ENDIF

    hImg = GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )

    IF cExt != "GIF"
        GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
    ELSE
        GDIPLUSSAVEOCTREEGIF( hImg, ANSITOWIDE( cDstFile ) )
    ENDIF

    GDIP_DELETEIMAGE( hImg )

    RETURN .T.


Code: Select all  Expand view
Error: Unresolved external '_HB_FUN_GDIPLUSSAVEOCTREEGIF'


:-(

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 Enrico Maria Giordano » Wed Dec 09, 2015 1:38 pm

And the following sample still creates a bad quality GIF:

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

Postby Enrico Maria Giordano » Wed Dec 09, 2015 10:49 pm

Manuel,

any suggestions? :-)

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 » Thu Dec 10, 2015 5:58 pm

Yes, Enrico .
The function GDIPLUSSAVEOCTREEGIF( hImg, ANSITOWIDE( cDstFile ) ) for recording quality gif is not included in fwh and is not implemented your use in tgdibmp class.
Look your mail for obj file...
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image

Postby Enrico Maria Giordano » Thu Dec 10, 2015 6:16 pm

Manuel,

I've tried with QColorQuantizer.obj but the result is the same. :-(

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 Dec 10, 2015 6:18 pm

This is what I'm trying:

Code: Select all  Expand view
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 := UPPER( CFILEEXT( cDstFile ) )

    LOCAL nExt := ASCAN( aExt, cExt )

    LOCAL cId := aIds[ nExt ]

    LOCAL hImg

    IF !FILE( cSrcFile ) THEN RETURN .F.

    hImg = GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )

    GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )

    GDIP_DELETEIMAGE( hImg )

    RETURN .T.


Any ideas?

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 Dec 11, 2015 7:41 am

Enrico

Code: Select all  Expand view


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 := UPPER( CFILEEXT( cDstFile ) )

    LOCAL nExt := ASCAN( aExt, cExt )

    LOCAL cId := aIds[ nExt ]

    LOCAL hImg

    IF !FILE( cSrcFile ) THEN RETURN .F.

    hImg = GDIPLUSIMAGELOADCACHEDFILE( cSrcFile )

  IF cExt != "GIF"
        GDIPLUSIMAGESAVE( hImg, ANSITOWIDE( cDstFile ), ANSITOWIDE( cId ) )
    ELSE
          GDIPLUSSAVEOCTREEGIF( hImg, ANSITOWIDE( cDstFile ) )  // I'm not sure  but I think plenty ANSITOWIDE()  
    ENDIF

    GDIP_DELETEIMAGE( hImg )

    RETURN .T.

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

Re: To save an image

Postby Enrico Maria Giordano » Fri Dec 11, 2015 9:28 am

Manuel,

sorry but the program does nothing. :-(

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 Dec 11, 2015 9:51 am

The program crashes at GDIPLUSSAVEOCTREEGIF() without error messages.

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 Dec 11, 2015 10:07 am

Enrico look your mail ...
For me is good . :-)
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: To save an image

Postby Enrico Maria Giordano » Fri Dec 11, 2015 10:23 am

Manuel,

is the OBJ for xHarbour?

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

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Natter and 55 guests