Hi everyone,
I see the post is quite old but since #russellman recently revived it, I'll give it a try since it's about something I need :-)
I was playing with
CrossFade and it's somehow working but there is something I can't figure out.
I have 2 BGRABitmaps, lets name them
img1 and
img2.
Img1 is non-transparent picture but
img2 is partly transparent. I need to merge them but without any calculating partly transparent pixels whatsoever.
Img2 consists of either 100% transparent pixels or 100% opaque color pixels. I need the 100% opaque pixels to just replace the pixels from
img1 and the 100% transparent pixels just keep the original pixels from
img1.
so my first shot was:
img.CrossFade(Rect(0,0,img1.Width,img1.Height), img1, img2, 255, dmSet);
but it resulted in
img be the same as
img2, it took just 1ms though.
Then I started playing with
mode value but all of them resulted in the same,
img =
img1, just taking 5-8ms.
Next I changed 255 to 254 and this did the trick, I got expected result but it took 26-28ms, depending on the
mode.
I just don't understand why 255 doesn't give the result I expected. It looks like 254 causes the function to calculate the
img1 and
img2 pixels, that's why it's taking so much more time. Even though it visually looks good,
img2 seems to cover
img1 in "just" 254/255, am I wrong?
Is
AFadePosition and equivalent of opacity? Setting a value between 0 and 254 gives results as if it were but everything changes with 255.
Searching for any answer led me to this post and #russellman's using
PutImage instead of
CrossFade. By these functions names I'd say that
CrossFade really calculates transparency according to
AFadePosition whereas
PutImage just drops one image onto another.
PutImage indeed gives expected result in just 7ms. How
PutImage different to
CrossFade?
Could someone shed more light on it?
Thanks in advance!