transparent GIF problem

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

Moderators: XnTriq, helmut, xnview

mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

transparent GIF problem

Post by mindplay »

I'm trying to generate a transparent GIF with GFLax in ASP, but I've run into a problem. Let's say I do this:

Code: Select all

<%

Const AX_GIF = 2
Const AX_To8Colors = 8
Const AX_NoDither = 0
Const AX_ToColors = 0

BG = RGB(255,255,255)
FG = RGB(255,0,0)
Text = "This is a test"

Set Pic = Server.CreateObject("GflAx.GflAx")
Pic.EnableLZW = True

Pic.FontName = "Verdana"
Pic.FontSize = 36

W = Pic.GetTextWidth(Text)
H = Pic.GetTextHeight(Text)

Pic.NewBitmap W, H, BG
Pic.TextOut Text, 0, 0, FG

Pic.SaveFormat = AX_GIF
Pic.ChangeColorDepth AX_To8Colors, AX_NoDither, AX_ToColors
Pic.UseTransparency = True
Pic.MaskColor = Pic.GetColorAt(0,0)
Pic.SaveBitmap Server.MapPath("test.gif")

%>
<HTML>
<HEAD></HEAD>
<BODY><IMG SRC="test.gif"></BODY>
</HTML>
Look here for the result ... as you can see, the red color is masked out as transparent, but the color at (0,0) is white. I've checked that GetColorAt(0,0) returns FFFFFF - this is true. I also tried RGB(255,255,255) which gives the same result ... so the error must lie within the transparency/maskcolor/savebitmap functions?
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

Anybody else experienced this problem? Anyone know the cause, or know if there's any way to work around it?
User avatar
xnview
Author of XnView
Posts: 44920
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

mindplay wrote:Anybody else experienced this problem? Anyone know the cause, or know if there's any way to work around it?
Ok, the problem is antialias!
Perhaps by adding a FontAntialias property will fixed the problem!
Pierre.
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

I don't see how that could be the problem? it shouldn't matter what's in the image in the first place - since I convert it to 8 colours first, the image has a palette ... normally, when you create a transparent GIF, that's what you do - reduce to x number of colors, then pick the color you want to be transparent.

If I set a specific MaskColor, shouldn't it mask that color out? otherwise what's the point of having MaskColor? setting it doesn't seem to have any effect at all?
User avatar
xnview
Author of XnView
Posts: 44920
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

mindplay wrote:I don't see how that could be the problem? it shouldn't matter what's in the image in the first place - since I convert it to 8 colours first, the image has a palette ... normally, when you create a transparent GIF, that's what you do - reduce to x number of colors, then pick the color you want to be transparent.

If I set a specific MaskColor, shouldn't it mask that color out? otherwise what's the point of having MaskColor? setting it doesn't seem to have any effect at all?
But here you have not a text in red, zoom in...
Pierre.
mindplay
Posts: 16
Joined: Wed Sep 21, 2005 9:30 am
Location: Denmark

Post by mindplay »

Yes, the edge pixels are not full-intensity red - I also don't want those masked out, so that's not a problem. But look at the code:

Pic.MaskColor = Pic.GetColorAt(0,0)

The color at 0,0 is the background color, WHITE, FFFFFF ... not red.

So white should be masked out - not red.

But it doesn't seem to matter WHAT I set MaskColor to - white OR red, it always masks out the same thing ... this property doesn't seem to have any effect at all?
User avatar
xnview
Author of XnView
Posts: 44920
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Post by xnview »

mindplay wrote:Yes, the edge pixels are not full-intensity red - I also don't want those masked out, so that's not a problem. But look at the code:

Pic.MaskColor = Pic.GetColorAt(0,0)

The color at 0,0 is the background color, WHITE, FFFFFF ... not red.

So white should be masked out - not red.

But it doesn't seem to matter WHAT I set MaskColor to - white OR red, it always masks out the same thing ... this property doesn't seem to have any effect at all?
Ok, right. Send me your a PM with your email, and i'll send you a beta version.
Pierre.