Archived

This topic is now archived and is closed to further replies.

wolfbane

Newbie simple 2d graphics question

Recommended Posts

wolfbane    122
I have just got into programming with graphics using Java and am having a lot of fun with it. (much better than borring Swing). Anyway, my question is this: if I have a bitmap that is a character and has a black background, how do I omit the background so I have just the character remaining? I wish to do this so when I animate him walking you would see the background tile that i have setup and not the black bitmap background. Any response would be very much appreciated. Wolfbane.

Share this post


Link to post
Share on other sites
This topic maybe belongs in the Java forum, but what you are talking about is sometimes called "masks". If you were coding at low level this means that for drawing the sprite you would simple skip any pixels which had a colour of Black (R=0, G=0, B=0). Thus, these pixels are never added to the screen.

Usually a colour like Pure Magenta (R=255, G=0, B=255) is used instead of Black because it is less likely to appear in a sprite (unless you''re doing a Barbie title), and it''s a simple colour (red and blue are maxed out, green is zero).

How to make it happen in Java, I can''t help you there, but I know it''s possible.

Trevize

----------------
"it was over, ever since you went and shot me
like a harpoon, like a harpoon, like a harpoon in my heart"
- jebediah

Share this post


Link to post
Share on other sites
Simple...

Set the background color as your transparency color, when drawing the sprite if the pixel in the bitmap is a color value equal to the transparency color you don't draw it to screen. Only pixels which are not the background color of the bitmap get drawn for your sprite.

-EDIT-
Note to self: Refresh page to check for other replies on such a simple topic before posting.
-EDIT-

Edited by - thewayout_is_through on February 7, 2002 1:06:37 AM

Share this post


Link to post
Share on other sites
JNewt    122
This is called Blitting. Chances are you can find a library or whatever they''re called in Java, that will have a function called BitBlt.

Share this post


Link to post
Share on other sites