- Online Community Forums » Programming Questions » Transparent Bitmaps

This thread is locked; no one can reply to it. rss feed Print
Transparent Bitmaps
Member #8,469
March 2007

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?

Member #2,559
July 2002

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

Tomasu: Every time you read this: hugging!

Ryan Patterson - <>

Matt Smith
Member #783
November 2000

Also, the first drawing primitive you'll need is

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

Dustin Dettmer
Member #3,935
October 2003

Maybe this thread deserves a wiki page?

Go to: