Page 1 of 1

Artefacts when using AlphaBltFast

PostPosted: Jul 10, 2002 @ 12:42am
by efortier
I'm using an alpha bitmap to blit some button on a screen, and I'm getting a strange artefact. To test it, I created this bitmap:

You will see the magenta doodle I made in the upper-right corner.

And here is the result, when using alpha blending, with no opacity:

I resized the image to 8x its size so that we clearly see the artefact. I didn't touch the colors.

Granted, the artefact is not very heavy, but it still is an artefact, and is apparent sometimes.

I use AlphaBltFast, and no blitting flags with not structure.

Is this normal? Shouldn't this artefact be invisible since the bottom part of the source image (the alpha channel) contains RGB(0,0,0) at that location?


PostPosted: Jul 10, 2002 @ 12:57am
by Johan
Thanks for this one as well.. Will look into it immediately.

PostPosted: Jul 10, 2002 @ 1:02pm
by Johan

I did not get the result you got. I got a perfect alpha blend to a black background using the source image Button_EndTurn2.png.

Somehow ALL RGB values in your source image were raised by 24 steps. You can easily check this if you look at the green button color in the res.png, which differs from the source image (also check my result below).

I would say that this is 99% a result from the built-in Gamma correction in LibPNG (which also apparantly adjusts the black level). When decoding the source image, LibPNG felt your monitor wasn't bright enough and increased the level of the image... This also raised the black level, which means that the alpha background now was gray and the pink scrap was copied as well. The error should not be visible on a PocketPC.

You can compare the different results below:

res.png (the incorrect result)

myres.png (my result)

What OS was used to render the res.png image? What graphic card?

The fun part is that I have disabled gamma in libpng. So it should not be active...


PostPosted: Jul 10, 2002 @ 11:16pm
by efortier

So, it's possible that it produce artefacts on a PC, but none on a PocketPC?

Does this mean that we never have control on what the PNG decompressor does to an image (on the PC)?

I'm working on Windows 2000 Pro SP2, with an MSI GeForce 3 Ti 200.

You are right that squinting or not, I can't see any artefact on my iPaq.

Thanks for helping. Live and learn!


PostPosted: Jul 10, 2002 @ 11:49pm
by Johan

I have gone through the code again and am certain this issue is related to LibPNG. It will not be visible on handheld devices because PocketPCs and Smartphones use their own built-in IMGDECMP.DLL routines. I use a high-level read mechanism introduced with later builds of libpng that is probably not as tested as the rest of the library.

A new version of LibPNG was released two days ago that fixes many memory leaks, and judging from their wonderful code standard I bet we will see numerous fixes to their library during the next couple of months... Hopefully one of them will fix this issue as well.