To save an image

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

Re: To save an image [Solved]

Post by mastintin »

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


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
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]

Post by Enrico Maria Giordano »

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

Code: Select all | Expand

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

Re: To save an image [Solved]

Post by mastintin »

Enrico . The problem is with magic.bmp . Is bmp PixelFormat8bppIndexed ( not normal bmp ).
I send a new obj file ...
User avatar
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]

Post by Enrico Maria Giordano »

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

Code: Select all | Expand

#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

Error: Unresolved external '_HB_FUN_GDIPLUSSAVEOCTREEGIF'


:-(

EMG
User avatar
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]

Post by Enrico Maria Giordano »

And the following sample still creates a bad quality GIF:

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

Re: To save an image

Post by mastintin »

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
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

Post by Enrico Maria Giordano »

Manuel,

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

EMG
User avatar
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

Post by Enrico Maria Giordano »

This is what I'm trying:

Code: Select all | Expand

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

Re: To save an image

Post by mastintin »

Enrico

Code: Select all | Expand



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
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

Post by Enrico Maria Giordano »

Manuel,

sorry but the program does nothing. :-(

EMG
User avatar
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

Post by Enrico Maria Giordano »

The program crashes at GDIPLUSSAVEOCTREEGIF() without error messages.

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

Re: To save an image

Post by mastintin »

Enrico look your mail ...
For me is good . :-)
User avatar
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

Post by Enrico Maria Giordano »

Manuel,

is the OBJ for xHarbour?

EMG
Post Reply