alphablending - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: alphablending (/thread-8373.html) |
alphablending - wallace - 11-10-2005 I have two arrays, a smaller getter() array and a buffer() array. Curently this is my code to blend them Code: SUB alphaput(x as integer, y as integer, x2 as integer, y2 as integer, getarray() as integer, destinationarray() as integer) Its painfully slow. Does anbody know of any way to improve it. I hope there is a lot that can be done. alphablending - Z!re - 11-10-2005 iirc FB PUT has built in alphablending by specifying the ALPHA flag: put buffer, (x, y), buffer, alpha Other than that, not much to be done, software alphablending is pretty slow.. alphablending - wallace - 11-10-2005 oh, I gotta get the new version. .14 gives me a syntax error. alphablending - d.j.peters - 11-10-2005 You can use pointers too pseudo code Code: type color32 but the alpha code in libgfx2 is optimized in MMX assembler and very fast. Joshy Code: option explicit alphablending - wallace - 11-10-2005 The problem that I was having when I was using it, is that I am trying to make the program extremely expandable. This means support for 15, 16, 24, and 32 bit depth. alphablending - d.j.peters - 11-10-2005 After an Screen or ScreenRes command FreeBASIC will handel all 15, 16, 24, and 32 bit depth for you. Joshy for FB 15,16 are the same format and 24,32 too alphablending - wallace - 11-10-2005 oh Quote:If the ALPHA mode is used, you can also specify an optional alpha parameter, The part about only 32 bit confused me, but I still must be doing somthing wrong, its not working. nevermind, i didn't see the part about the alpha parameter alphablending - lillo - 11-10-2005 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 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 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... |