Transparent Bitmaps
moon_rabbits

I have a bitmap that is created like this

tank = create_bitmap(TANK_W, TANK_H);

And drawn to with primitives:

// draw tank to tank bitmap
    rectfill(tank, 10, 0, (TANK_W-10), TANK_H-(TANK_H/4), makecol(45, 200, 60));
    rect(tank, 10, 0, (TANK_W-10), TANK_H-(TANK_H/4), makecol(60, 230, 70));
    ellipsefill(tank, (TANK_W/2), TANK_H-(TANK_H/4), (TANK_W/2), (TANK_H/4), makecol(160, 160, 160));
    ellipse(tank, (TANK_W/2), TANK_H-(TANK_H/4), (TANK_W/2), (TANK_H/4), makecol(120, 120, 120));

A background is blitted to the screen, and then this tank is blitted at it's (x,y) location on top of the background.

It just makes a green recangle and grey wheels out of an ellipse. However, because the rectangle and ellipse do not cover the entire bitmap, there are still black areas on the bitmap that were not drawn on.

How can I make these transparent, so that the background is displayed instead of the black, blank bitmap?

CGamesPlay

The function you need is:masked_blitRead that for how to accomplish what you want.

Matt Smith

Also, the first drawing primitive you'll need is

because bitmaps are created with color 0, which is only transparent in 8 bit mode.

ImLeftFooted

Maybe this thread deserves a wiki page?

Thread #590748. Printed from Allegro.cc