Bad quality with GIF (and GDI+)

Re: Bad quality with GIF (and GDI+)

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8374
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bad quality with GIF (and GDI+)

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


Re: Bad quality with GIF (and GDI+)

Postby nageswaragunupudi » Tue Nov 03, 2015 11:15 am

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bad quality with GIF (and GDI+)

Postby mastintin » Tue Nov 03, 2015 11:49 am

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

Re: Bad quality with GIF (and GDI+)

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bad quality with GIF (and GDI+)

Postby Enrico Maria Giordano » Tue Nov 03, 2015 12:04 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8374
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bad quality with GIF (and GDI+)

Postby mastintin » Tue Nov 03, 2015 1: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.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm


Re: Bad quality with GIF (and GDI+)

Postby mastintin » Wed Nov 04, 2015 5:49 pm

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

.....

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

Re: Bad quality with GIF (and GDI+)

Postby nageswaragunupudi » Wed Nov 04, 2015 5:58 pm

Mr Manuel

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Re: Bad quality with GIF (and GDI+)

Postby mastintin » Wed Nov 04, 2015 7: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: 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 ) ;
........

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

Re: Bad quality with GIF (and GDI+)

Postby mastintin » Wed Nov 04, 2015 7:32 pm

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

Re: Bad quality with GIF (and GDI+)

Postby Enrico Maria Giordano » Wed Nov 04, 2015 8:45 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8374
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Horizon and 41 guests