Results 1 to 6 of 6

Thread: Manualy Alpha blending two colors

  1. #1

    Manualy Alpha blending two colors

    How to manualy calculate resulting color by Alphablending two existing colors?

  2. #2
    I have done something like this some days ago!

    This link help-me a lot! http://en.wikipedia.org/wiki/Alpha_compositing


    The formula I used was this one :

    outRGB = srcRGB * srcAlpha + destRGB * (1-srcAlpha)

  3. #3
    Do you have any source code? I have seen that article and tried to implement it on my own, but I don't seem to get it working right.

    Also I'm trying to implement seperate calculations for each color chanell (red, green, blue).

  4. #4
    That's what he meant i think. Try formula for each channel:
    outR := srcR * srcAlpha + destR * (1-srcAlpha);
    outG := srcG * srcAlpha + destG * (1-srcAlpha);
    outB := srcB * srcAlpha + destB * (1-srcAlpha);

  5. #5
    Actually, the simplest (and slightly faster) alpha-blending equation is:
    Code:
     Dest.R = Src1.R  + (Src2.R - Src1.R) * Alpha;
     Dest.G = Src1.G  + (Src2.G - Src1.G) * Alpha;
     Dest.B = Src1.B  + (Src2.B - Src1.B) * Alpha;
    where Dest is the final color, Src1 and Src2 are the source colors with Alpha in [0..1] range.

  6. #6
    Thanks guys. That works like charm.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •