Hello,
in my image viewer I need to blit a source bitmap S onto a destination one D, in a way that S transpares D that is behind (transparency effect). Say that neither S nor D necessarily have transparent areas.
How to achieve it? Hardware acceleration possible?
Thanks, regards
You can do that with the CompositeTags() function from graphics.library.
@salass00
Thanks.
CompositeTags() seems able to perform a variety of things, a specific code snippet would help a lot.
See boing2.c and boing3.c examples here:
https://dl.dropboxusercontent.com/u/26599983/boing.lha
@salass00
Thanks, very handy examples.
See Aminet/CompositePOC
Alain
Alain Thellier - Wazp3D
@thellier
Thanks, will check that too.
@salass00
@thellier
If I understand well, both Source and Destination must be partially transparent to achieve the transparency effect, say a constant alpha factor = 0.5 (50% of opaqueness and 50% of transparency), or rather
COMPTAG_SrcAlpha, COMP_FLOAT_TO_FIX( 0.5 )
COMPTAG_DestAlpha, COMP_FLOAT_TO_FIX( 0.5 )
for CompositeTags().
Say that neither Source nor Destination necessarily have transparent areas.
Am I wrong? Something that I am not taking in consideration?
Thanks
@salass00
@thellier
I correct myself, I think to make it possible that S (source) transpares D (destination) that is behind, only S has to be partially transparent while D can be fully opaque (the other way round should be possible as well).
Supposing S and D don' t have transparent areas and I want S to have 50% of opaqueness and 50% of transparency:
IGraphics->CompositeTags( COMPOSITE_Src_Over_Dest, Source, Destination,
/* ... */
COMPTAG_SrcAlpha, COMP_FLOAT_TO_FIX( 0.5 ),
COMPTAG_Flags, COMPFLAG_SrcAlphaOverride | COMPFLAG_IgnoreDestAlpha,
TAG_DONE );
What do you think about it?
That should be correct. I'm not sure why you are asking rather than just testing the code yourself though.
Rather than using COMP_FLOAT_TO_FIX( 0.5 ) you could also just input the fixed point value directly which would be 0x8000.
@salass00
Thanks.
Not always I can use my OS4 system on a daily basis :(
Will test that as soon as possible.
@salass00
I got it to work, I now have a catchy transparency effect as I wanted and expected.
Thanks again.