Page 5 of 6

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 10:17 am
by Enrico Maria Giordano
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

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 10:28 am
by mastintin
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

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 10:35 am
by Enrico Maria Giordano
It works!!! :-)

EMG

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 11:15 am
by nageswaragunupudi
Mr Manuel

Code: Select all  Expand view
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?

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 11:49 am
by mastintin
nageswaragunupudi wrote:Mr Manuel

Code: Select all  Expand view
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

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 11:56 am
by nageswaragunupudi
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.

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 12:04 pm
by Enrico Maria Giordano
I confirm. All images loaded with GDI+ are "marked" as alphachannel even if they are not.

EMG

Re: Bad quality with GIF (and GDI+)

PostPosted: Tue Nov 03, 2015 1:11 pm
by mastintin
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.

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 11:25 am
by Enrico Maria Giordano
Any news? :-)

EMG

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 5:49 pm
by mastintin
Nages and this solution?


Code: Select all  Expand view


.....

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

.....

 

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 5:58 pm
by nageswaragunupudi
Mr Manuel

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

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 6:56 pm
by Enrico Maria Giordano
I'm ready to test it. :-)

EMG

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 7:11 pm
by mastintin
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: Select all  Expand view


.......

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

 

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 7:32 pm
by mastintin

Re: Bad quality with GIF (and GDI+)

PostPosted: Wed Nov 04, 2015 8:45 pm
by Enrico Maria Giordano
Probably I'm doing something wrong but it doesn't work (GIFs are still bad rendered).

EMG