FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bad quality with GIF (and GDI+)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 10:17 AM
mastintin wrote:
Enrico Maria Giordano wrote:On XP and Vista your sample shows a black rectangle. :-)

EMG


https://support.microsoft.com/es-es/kb/958911


Ok, thank you.

EMG
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 10:28 AM
Enrico Maria Giordano wrote:
mastintin wrote:
Enrico Maria Giordano wrote:On XP and Vista your sample shows a black rectangle. :-)

EMG


https://support.microsoft.com/es-es/kb/958911


Ok, thank you.

EMG


first confirm is ok. ...
link this gdiplus.obj file in your code ...
https://www.dropbox.com/s/ah0f235yqbe5a ... s.obj?dl=0
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 10:35 AM

It works!!! :-)

EMG

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 11:15 AM
Mr Manuel

Code (fw): Select all Collapse
 Bitmap* newImage  = new Bitmap( nWidth, nHeight, PixelFormat32bppPARGB ) ; //   cambio aqui ---- original->GetPixelFormat() );


This is the change you made. That means this function adopts "PixelFormat32bppPARGB" for "all" image/bitmap files, irrespective of the source and present pixelformat.
Does it have any side effects on other file formats?
Regards



G. N. Rao.

Hyderabad, India
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 11:49 AM
nageswaragunupudi wrote:Mr Manuel

Code (fw): Select all Collapse
 Bitmap* newImage  = new Bitmap( nWidth, nHeight, PixelFormat32bppPARGB ) ; //   cambio aqui ---- original->GetPixelFormat() );


This is the change you made. That means this function adopts "PixelFormat32bppPARGB" for "all" image/bitmap files, irrespective of the source and present pixelformat.
Does it have any side effects on other file formats?


I've been using it time and have not had any problems.
actually we assume that all "imported" to gdi+ is 32bit (highest quality) then return HBITMAP not had problem
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 11:56 AM

One of the cases I can now recollect is non-alpha bmp files.
The hBitmap returned is an alpha bmp. We get into problem while rendering.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 12:04 PM

I confirm. All images loaded with GDI+ are "marked" as alphachannel even if they are not.

EMG

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bad quality with GIF (and GDI+)
Posted: Tue Nov 03, 2015 01:11 PM
nageswaragunupudi wrote:One of the cases I can now recollect is non-alpha bmp files.
The hBitmap returned is an alpha bmp. We get into problem while rendering.


Yes, same case in GDIP_IMAGEFROMFILE -> BitmapFromStream ....

....
PixelFormat pf = original->GetPixelFormat();

if ( pf != PixelFormatUndefined && ( ! IsExtendedPixelFormat( pf ) ) )
{
newImage = new Bitmap( nWidth, nHeight, ( pf == PixelFormat32bppRGB ? PixelFormat32bppPARGB : pf ) );

if ( pf == PixelFormat32bppRGB ) // AlphaBmp: Need to do additional work
....

by now there have been no trouble for it.
another solution is to put a exception for gif.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 11:25 AM

Any news? :-)

EMG

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 05:49 PM
Nages and this solution?


Code (fw): Select all Collapse
.....

 int nWidth  = original->GetWidth()  ;
 int nHeight = original->GetHeight() ;

 PixelFormat pf ;
  
 if( strncmp( adr, "GIF", 3 ) != 0 )   // detect if file is a gif type. 
       pf = original->GetPixelFormat();
  else
      pf = PixelFormat32bppPARGB ;
    
  Bitmap* newImage  = new Bitmap( nWidth, nHeight, pf ) ;

 Graphics * graphics = new Graphics( newImage );

.....
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 05:58 PM

Mr Manuel

So your proposal is to force 32bppPARGB for GIFs.
Done it.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 06:56 PM

I'm ready to test it. :-)

EMG

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 07:11 PM
nageswaragunupudi wrote:Mr Manuel

So your proposal is to force 32bppPARGB for GIFs.
Done it.

yes.
another option ...
pass a new parameter that specifies that we want to use 32 bits

Code (fw): Select all Collapse
.......

PixelFormat pf ;
     pf = original->GetPixelFormat();
 
bool l32bpp = hb_parl( 2)   

  if (  ( strncmp( adr, "GIF", 3 ) == 0  )  &  ( l32bpp == TRUE )   ) 
            pf = PixelFormat32bppPARGB ;
    
  Bitmap* newImage  = new Bitmap( nWidth, nHeight, pf ) ;
........
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 07:32 PM

Enrico . For your test ...

https://dl.dropboxusercontent.com/u/132931/gdiplus.obj
Cheers.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bad quality with GIF (and GDI+)
Posted: Wed Nov 04, 2015 08:45 PM

Probably I'm doing something wrong but it doesn't work (GIFs are still bad rendered).

EMG