Blitting Semi-Transparent

Started by
3 comments, last by Scooter 23 years, 6 months ago
How do i blit a bitmap semi-transparently?
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
Advertisement
I'm not sure if DD 8.0 supports it, but do a search for translucency or alpha-blending. You can do it manually too.. just take each pixel and do something like this:

ForegroundPixel + BackgroundPixel /2 = NewPixel

(obviously doing that for the RG&B components seperately)

The above will give you 50% tranlucency. I had the formula for variable translucency somewhere, but I lost it when formated one of my hard drives. From what I remember, you take each color value and multiply it by a %. 1.0 for opaque, 0.0 for invisible, 0.5 for half-way, etc..

Edited by - A. Buza on October 3, 2000 7:13:24 PM
Hi there,

I use the following

        #define BLEND(src,dest,alpha)    (((alpha*(src-dest))>>8)+dest)#define BLEND50(src,dest,alpha)  ((src+dest)*0.5)    


Hope it helps.


Edited by - MButchers on October 4, 2000 6:35:16 AM
So each frame, i''d have to get the dest. r,g,b and do the blend with the source r,g,b colors individually? doesn''t this eat up alot of time?
We are here just like this,It really doesn't matter why.The world is here like it is,'We could laugh we could cry.Is it good or is it bad,Wright or maybe wrong?There's no use of being sad,Without a purpose within a song.
yes, it''s very CPU expensive.
if you want it to go faster you can either optimize it for MMX (i think there is a tutorial on gamedev), or use d3d, which of course requires a hardware accelerator.

This topic is closed to new replies.

Advertisement