How would I go about cutting out the background of bitmaps so that you only see the sprite? and not the entire colored background.
Printable View
How would I go about cutting out the background of bitmaps so that you only see the sprite? and not the entire colored background.
You need to decide on a transparent color. This color will be in the sprite image but your code or the blitting code will not write these pixels to the screen or buffer. You need to use a color that you would not likely use in any image such as very very bright colors (255,255,0) or something like that.
If you are using DirectX there are functions that will do this for you in any color depth provided that you tell it what the transparent color is. It is a little more difficult with DX8 and DX9 because DirectX has been merged with D3D and blits can become complicated. For a more detailed explanation of this check www.gamasutra.com or www.gamedev.net - I think www.gamedev.net has a tutorial for creating 2D games with DX8.
If you are in DOS you really need to use assembly to get the function to be quick enough. Simply scan the image to be into the buffer, check for the transparent color, is it is the transparent color, advance in the frame buffer (screen or back buffer) without plotting pixels and advance in the image buffer or sprite. Do this for the entire image to be blitted and you are done. Very simple really.
The PNG format has support for transparency without having to choose a transparent color (color keying).
Load the images with the D3DXCreateTextureFromFileEx() function.
OpenGL, I am using.
Is this what I'm looking for? http://www.macscene.org/ppcdc/print.php?p=rectblit
hey drdroid, IM me, i've got some code to load transparent BMPs that works VERY nicely :) I use it all the time