Hi Everybody,

It's now possible to do real alpha blending in PicoGUI! At this point, 
it doesn't have any accelerated implementations, so it could be slow. 
Also, images with alpha channels take more memory of course. But, it 
works! There's a screenshot up on picogui.org

So how does alpha blending compare to using AND/OR masks to draw 
transparent bitmaps? In high color depths, using alpha blending 
actually saves memory. This is because AND/OR masks require two images, 
while alpha blending requires one 32bpp image. If you're in a 32bpp 
video mode anyway, you don't need any extra memory. In low color 
depths, AND/OR masks are much more efficient. Two 2bpp images take up 
the same memory as one 4bpp image, as compared to a 32bpp image with an 
alpha channel. For speed, AND/OR masks also win. At the moment no 
acceleration has been written, and even with the proper acceleration 
functions alpha blending still requires multiple multiplication and bit 
shift operations per pixel.

So, in short- only use alpha blending if you need the extra effects, or 
if you're in a high color depth and want to save memory regardless of 
the drawing speed. If you want to use alpha blending, here's a few 
things you should know:

  - PicoGUI colors can be in ARGB format if they have the PGCF_ALPHA 
flag. Since the flag takes one bit, you actually end up with a 7-bit 
alpha channel, and 8 bits for R, G, and B. For example, the color 
(0x00000000 | PGCF_ALPHA) is completely transparent, (0x7FFFFFFF | 
PGCF_ALPHA) is opaque white, and (0x40FFFF00 | PGCF_ALPHA) is 
translucent yellow.

  - Bitmaps are normally stored in the video display's native format. 
Images with alpha channels must be forced to use 32-bit color

  - The PNG and GIF bitmap loaders will automatically create an image 
with an alpha channel if necessary. The entire image will be 32-bit and 
in ARGB format

  - To actually use these ARGB colors, you need to render using the 
PG_LGOP_ALPHA logical operation

  - The bitmap and button widgets use PG_LGOP_ALPHA automatically if 
the 0,0 pixel in the image has the PGCF_ALPHA flag

Share and Enjoy :)

--Micah

_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel

Reply via email to