• Announcements

Archived

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

Blitting Semi-Transparent

Recommended Posts

How do i blit a bitmap semi-transparently?

Share on other sites
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

Share on other sites
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

Share on other sites
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?

Share on other sites
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.

• Forum Statistics

• Total Topics
627735
• Total Posts
2978855

• 10
• 10
• 21
• 14
• 12