Loading transparent pictures > background color?

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

Post Reply
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Loading transparent pictures > background color?

Post 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 );
User avatar
xnview
Author of XnView
Posts: 43601
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Loading transparent pictures > background color?

Post by xnview »

You have the transparency index in GFL_BITMAP
Pierre.
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Re: Loading transparent pictures > background color?

Post 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.
User avatar
xnview
Author of XnView
Posts: 43601
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Loading transparent pictures > background color?

Post 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?
Pierre.
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Re: Loading transparent pictures > background color?

Post by AmigoJack »

xnview wrote:Could you send me a GIF sample?
Several.
Attachments
transparent_images.zip
Contains 3 GIFs, 1 ICO and 1 CUR - all have .TransparentIndex = -1
(1.51 KiB) Downloaded 152 times
User avatar
xnview
Author of XnView
Posts: 43601
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Loading transparent pictures > background color?

Post 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...
Pierre.
User avatar
AmigoJack
Posts: 33
Joined: Tue Mar 09, 2010 6:40 pm
Contact:

Re: Loading transparent pictures > background color?

Post 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?
User avatar
xnview
Author of XnView
Posts: 43601
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Loading transparent pictures > background color?

Post 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
Pierre.
Post Reply