Page 1 of 1

Loading transparent pictures > background color?

Posted: Wed Jun 23, 2010 11:13 am
by AmigoJack
I've searched numerous topics and have not found one useful example (code language does not matter) on how to avoid a black background when loading a picture which supports transparence. It happens with GIFs, PNGs and ICOs at least.

Can anybody give an example on how to set/define a background color to be used when loading the picture? Can be Delphi, C++, VB... anything. Thanks.

What I use so far:

Code: Select all

var
  vFileInfo: GFL_FILE_INFORMATION;
  vLoadParam: GFL_LOAD_PARAMS;
  pBmp: PGFL_BITMAP;
  iError: GFL_ERROR;
begin
  gflGetDefaultLoadParams( vLoadParam );
  vLoadParam.ColorModel:= GFL_BGR;
  vLoadParam.LinePadding:= 4;
  iError:= gflLoadBitmap( 'file.ico', @pBmp, @vLoadParam, vFileInfo );

Re: Loading transparent pictures > background color?

Posted: Wed Jun 23, 2010 4:00 pm
by xnview
You have the transparency index in GFL_BITMAP

Re: Loading transparent pictures > background color?

Posted: Wed Jun 23, 2010 4:50 pm
by AmigoJack
xnview wrote:You have the transparency index in GFL_BITMAP
Yes, you answered the same in a couple of threads. But not more. It seems obvious to you what to do with it, but not to me. :(

What should I do with it? I suspect it's an index on the color palette - should I directly modify this color on the palette into RGBA white? It's a SmallInt - that makes its highest value 32767 - pretty low for all colors used on a palette, or am I missing something here?

Also: when loading my transparent ICOs, CURs or GIFs GFL_BITMAP.TransparentIndex is always -1.

Re: Loading transparent pictures > background color?

Posted: Thu Jun 24, 2010 7:34 am
by xnview
AmigoJack wrote: What should I do with it? I suspect it's an index on the color palette - should I directly modify this color on the palette into RGBA white? It's a SmallInt - that makes its highest value 32767 - pretty low for all colors used on a palette, or am I missing something here?
Yes it's the index of colormap
Also: when loading my transparent ICOs, CURs or GIFs GFL_BITMAP.TransparentIndex is always -1.
Could you send me a GIF sample?

Re: Loading transparent pictures > background color?

Posted: Thu Jun 24, 2010 8:07 am
by AmigoJack
xnview wrote:Could you send me a GIF sample?
Several.

Re: Loading transparent pictures > background color?

Posted: Fri Jun 25, 2010 11:28 am
by xnview
AmigoJack wrote:
xnview wrote:Could you send me a GIF sample?
Several.
For .ico/cur GFL doesn't support mask so TransparentIndex is always -1
For the GIF, the problem is 1bit, if you convert it in 4bits for example, there is no problem...

Re: Loading transparent pictures > background color?

Posted: Mon Jun 28, 2010 6:16 am
by AmigoJack
xnview wrote:For .ico/cur GFL doesn't support mask so TransparentIndex is always -1
Ok - but how to avoid a black background color when loading?
xnview wrote:For the GIF, the problem is 1bit, if you convert it in 4bits for example, there is no problem...
Ok, but how?

Re: Loading transparent pictures > background color?

Posted: Tue Jun 29, 2010 9:01 am
by xnview
AmigoJack wrote:
xnview wrote:For .ico/cur GFL doesn't support mask so TransparentIndex is always -1
Ok - but how to avoid a black background color when loading?
Currently there is no way
xnview wrote:For the GIF, the problem is 1bit, if you convert it in 4bits for example, there is no problem...
Ok, but how?
I means, if you have a 4bits GIF file