Archived

This topic is now archived and is closed to further replies.

Axenation

plotting alpha'd pixels

Recommended Posts

Hi, im trying to plot an alpha-blended pixel to the display surface (screen), but it''s not showing up translucent. Is this possible? My display surface is set up for 32 bits-per-pixel, and my putpixel function supports 32 bits-per-pixel. Im, guessing it might be a problem with my video card (i can''t get it to work correctly, WinXP-PRO gives me a "this device cannot start" error when installing it, so i have no hardware support). any info/suggestions would be well appreciated.
   
for( int x=0; x<255; x++ )
{
  for( int y=0; y<255; y++ )
  {
    putpixel( screen, x, y, 
      SDL_MapRGBA(screen->format, 00, 00, 0xFF, x) );
  }
}

Share this post


Link to post
Share on other sites
You can't just plot pixels with alpha with the regular putpixel function that's in the sdl manual. you need to do the calculation

x' = a * x + (1 - a) * y,
where x' is the color of the pixel to be plotted and x is the color before the alpha blending, a is the alpha value of the pixel to be plotted and y is the pixel on the background. you have to calculate this to all the color components of the pixel (r,g,b).

-rixxx


---------------------------
for(goodness_sake())
{
do
{
something();
} while(you_can());
}


[edited by - rixxx on October 21, 2003 7:33:37 AM]

Share this post


Link to post
Share on other sites