Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
alphablending
#8
I'll try to better explain how PUT ALPHA mode works in gfxlib.
PUT supports two distinct ALPHA modes: an uniform mode and a per-pixel mode.
In the uniform mode, an unique alpha value is applied to your sprite that is thus uniformly blended onto the destination buffer. This means you supply an alpha value to PUT and this same value will be applied as alpha value to all the pixels of your sprite.
This mode is fast, and is useful if you do not plan to have parts of your sprite "more or less transparent" than other parts of the same sprite.
Uniform mode is achieved via the PUT form:
Code:
PUT [buffer], (x, y), sprite, ALPHA, value
Where value is the alpha value to be applied to all the pixels of the sprite.

The per-pixel mode allows to specify a different alpha value for each pixel composing your sprite; this alpha value is embedded directly into the pixel data, and since the only pixel format that allows to embed an alpha value is the RGBA 32bit format, this means this mode only works if you are using a 32bit screen mode.
Per-pixel alpha mode can be used by not specifying the alpha value when calling PUT:
Code:
PUT [buffer], (x, y), sprite, ALPHA
The alpha value in fact will be taken from each pixel stored in the sprite data.

This should answer your question about the 32bit part. Uniform alpha mode works in any direct-color depth (15, 16, 24 and 32bpp), as the pixel format does not require the alpha value (so 15, 16 and 24bpp are fine, even if they only sport a RGB and not an RGBA format). The per-pixel mode however requires an RGBA format and thus requires a 32bit mode.

The snippet you posted does not work as you probably want it to because the sprite data has 0 as alpha value for all pixels: in fact even if you are using a 32bit mode (you specified 24bpp, but 24 and 32 are equivalent in gfxlib and handled as 32bpp), you're using GET to get the sprite data from the screen, but you didn't specify an alpha value in your colors when drawing before using GET...
To specify an alpha value when drawing, use the &hAARRGGBB hex format for colors, or use the RGBA macro.

Hope it helps...
ngelo Mottola - EC++
Reply


Messages In This Thread
alphablending - by wallace - 11-10-2005, 12:59 AM
alphablending - by Z!re - 11-10-2005, 01:20 AM
alphablending - by wallace - 11-10-2005, 04:00 AM
alphablending - by d.j.peters - 11-10-2005, 04:26 AM
alphablending - by wallace - 11-10-2005, 06:02 AM
alphablending - by d.j.peters - 11-10-2005, 08:09 AM
alphablending - by wallace - 11-10-2005, 07:46 PM
alphablending - by lillo - 11-10-2005, 08:41 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)