Bad quality with GIF (and GDI+)
- 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:
Bad quality with GIF (and GDI+)
I'm using the new GDI+ function and they work very well with JPGs, TIFs and PNGs but GIFs are rendered with very bad quality.
Someone can confirm?
EMG
Someone can confirm?
EMG
- 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: Bad quality with GIF
This is a sample. Please look at the very bad quality of the result. Any workaround?
EMG
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: Bad quality with GIF (and GDI+)
Enrico .
We had a picture of 32 or 24 bits to 8 bits . The maximum number of colors is 256 for gif files.
The problem is that Microsoft gdi+ also uses the halftone palette (compatible 100% web) for gif conversion,which it makes the colors that are not in the table web It is changed to the nearest.
There is no easy solution
.
We would have to:
go to gdi1.0 to GDI 1.1 and some operating systems let out (not good).
It could save the original palette but not as we could tell GDI+ to use that instead the halftone palette when save image .
We had a picture of 32 or 24 bits to 8 bits . The maximum number of colors is 256 for gif files.
The problem is that Microsoft gdi+ also uses the halftone palette (compatible 100% web) for gif conversion,which it makes the colors that are not in the table web It is changed to the nearest.
There is no easy solution

We would have to:
go to gdi1.0 to GDI 1.1 and some operating systems let out (not good).
It could save the original palette but not as we could tell GDI+ to use that instead the halftone palette when save 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:
- 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: Bad quality with GIF (and GDI+)
mastintin wrote:go to gdi1.0 to GDI 1.1 and some operating systems let out (not good).
What Windows versions support GDI+ 1.1 natively?
EMG
Re: Bad quality with GIF (and GDI+)
Enrico Maria Giordano wrote:mastintin wrote:go to gdi1.0 to GDI 1.1 and some operating systems let out (not good).
What Windows versions support GDI+ 1.1 natively?
EMG
Vista and more ...
and some borland compiler not support gdi+1.1

Re: Bad quality with GIF (and GDI+)
more news...
https://msdn.microsoft.com/en-us/library/aa479306.aspx
here all code in C ++ to use ColorQuantizer.
http://www.codeguru.com/cpp/g-m/gdi/gdi ... ctrees.htm
https://msdn.microsoft.com/en-us/library/aa479306.aspx
here all code in C ++ to use ColorQuantizer.
http://www.codeguru.com/cpp/g-m/gdi/gdi ... ctrees.htm
Last edited by mastintin on Sun Nov 01, 2015 10:37 am, edited 1 time in total.
- 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: Bad quality with GIF (and GDI+)
mastintin wrote:more news...
https://msdn.microsoft.com/en-us/library/aa479306.aspx
I guess you can adapt the code. When you have a little time I look at you could do.
Do you mean *you* can adapt the code?

Thank you.
EMG
Re: Bad quality with GIF (and GDI+)
here all code in C ++ to use ColorQuantizer.
http://www.codeguru.com/cpp/g-m/gdi/gdi ... ctrees.htm
http://www.codeguru.com/cpp/g-m/gdi/gdi ... ctrees.htm
- 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: Bad quality with GIF (and GDI+)
I just made a test: I replace GDIP_IMAGEFROMFILE() with FILOADIMG() and the result is how is should be. So the problem seems to be located in the loading function GDIP_IMAGEFROMFILE() (and probably in GDIPLUSIMAGELOADCACHEDFILE() too).
I don't know if this can help though.
EMG
I don't know if this can help though.
EMG
Re: Bad quality with GIF (and GDI+)
Enrico , provisional solution .....
Change this Method in gdiplus class C:\fwh\source\clases\tgdiplus.prg
Change this Method in gdiplus class C:\fwh\source\clases\tgdiplus.prg
Code: Select all | Expand
METHOD Save( cFile , nQuality ) CLASS GDIBmp
local cExtension := Upper(cFileExt(cFile))
local cCLSID
local hQuality := nil
local nScan:= aScan( ::aExtEnd, cExtension )
//local cGUI := AnsiToWide("{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}" )
local cTempFile
if nScan == 0
msginfo( "Formato no soportado" )
Return .f.
endif
if cExtension == "GIF"
nScan := 1
endif
cCLSID := ::aCLSID[ nScan ]
cCLSID = AnsiToWide( cCLSID )
cFile = AnsiToWide( cFile )
if cExtension == "GIF"
cTempFile := cTempFile()
GdiPlusImageSave( ::hBmp, cTempFile, cCLSID )
FIConvertImageFile( cTempFile, cFile )
FErase( cTempFile )
else
if !Empty( nQuality ) .and. cExtension == "JPG"
GdiPlusImageSaveQuality( ::hBmp, cFile, cCLSID, nQuality )
else
GdiPlusImageSave( ::hBmp, cFile, cCLSID )
endif
endif
Return nil
- 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: Bad quality with GIF (and GDI+)
If I read correctly, it uses FreeImage, right? If yes, it's not a useful solution, sorry.
EMG
EMG