Blitting with alpha blend [ SOLVED ]

12 posts / 0 new
Last post
Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
Blitting with alpha blend [ SOLVED ]

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

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
You can do that with the

You can do that with the CompositeTags() function from graphics.library.

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@salass00 Thanks. CompositeT

@salass00

Thanks.
CompositeTags() seems able to perform a variety of things, a specific code snippet would help a lot.

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
See boing2.c and boing3.c

See boing2.c and boing3.c examples here:
https://dl.dropboxusercontent.com/u/26599983/boing.lha

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@salass00 Thanks, very handy

@salass00

Thanks, very handy examples.

thellier
thellier's picture
Offline
Last seen: 5 years 11 months ago
Joined: 2014-03-04 12:43
See

See Aminet/CompositePOC

Alain

Alain Thellier - Wazp3D

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@thellier Thanks, will check

@thellier

Thanks, will check that too.

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@salass00 @thellier If I

@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

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@salass00 @thellier I

@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?

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
Supposing S and D don' t have


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.

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@salass00 Thanks. Not always

@salass00

Thanks.
Not always I can use my OS4 system on a daily basis :(
Will test that as soon as possible.

Massi
Massi's picture
Offline
Last seen: 4 years 6 months ago
Joined: 2012-03-28 17:16
@salass00 I got it to work,

@salass00

I got it to work, I now have a catchy transparency effect as I wanted and expected.

Thanks again.

Log in or register to post comments