Bad quality with GIF (and GDI+)

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: Bad quality with GIF (and GDI+)

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

Re: Bad quality with GIF (and GDI+)

Post 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
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Bad quality with GIF (and GDI+)

Post by nageswaragunupudi »

Mr Manuel

Code: Select all | Expand

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

Re: Bad quality with GIF (and GDI+)

Post by mastintin »

nageswaragunupudi wrote:Mr Manuel

Code: Select all | Expand

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
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Bad quality with GIF (and GDI+)

Post 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.
Regards

G. N. Rao.
Hyderabad, India
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: Bad quality with GIF (and GDI+)

Post by Enrico Maria Giordano »

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

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

Re: Bad quality with GIF (and GDI+)

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

Re: Bad quality with GIF (and GDI+)

Post by mastintin »

Nages and this solution?


Code: Select all | Expand



.....

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

.....

 
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Bad quality with GIF (and GDI+)

Post by nageswaragunupudi »

Mr Manuel

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

G. N. Rao.
Hyderabad, India
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Bad quality with GIF (and GDI+)

Post 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



.......

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

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

Re: Bad quality with GIF (and GDI+)

Post by mastintin »

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: Bad quality with GIF (and GDI+)

Post by Enrico Maria Giordano »

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

EMG
Post Reply