Load
Loads the Bitmap from a bitmap file, which may contain an alpha channel. Returns true in success.
Loads the Bitmap from two separate bitmaps, one bitmap for the color information and one 8-bit bitmap for the transparency information. Returns true in success.
Loads the bitmap from an Allegro bitmap. If convertMagicPink is true the magic pink pixels in the bitmap will be converted to transparent pixels in the Bitmap. OpenLayer doesn't free the passed BITMAP even if the Bitmap is destroyed.
Same as above but the parameters are given by using a bitwise "or" of the following conversion parameters: HAS_ALPHA_CHANNEL and CONVERT_MAGIC_PINK. The loaded bitmap may be in any format that is supported by Allegro (bmp, pcx, tga) or by any add-on libraries you've installed (Loadpng for pngs or JPGAlleg for JPEGs, for example). Installing Loadpng is recommended as png files may contain an alpha channel to allow for transparent or translucent pixels. Png files also compress better than tga files. The latest OpenLayer's packages contain the loadpng, libpng and libz -libraries which are required to load png images. It's best to check if the loading succeedes or not. The file may not be found or the format may not be supported. OpenLayer logs all loading failures in allegro.log, though, so you can also check the log file to find out if the loading has failed. But instead of letting your program crash it's better to display a message for the end user to let him know what went wrong. You'll get better feedback for your game that way ;) Examples // Remember to call Setup::SetupProgram and Setup::SetupScreen before loading any bitmaps! //
// Load myBmp from gfx/Bitmap.png // Bitmap myBmp; myBmp.Load( "gfx/Bitmap.png" ); // It's best to check if the loading succeedes! (Bitmap really exists) // Bitmap myBmp; if( myBmp.Load( "gfx/Bitmap.png" ) == false ) { // Display an error message // allegro_message( "Bitmap couldn't be loaded!" ); // Exit the program // exit(-1); } // If you have BitmapColor.bmp that has the color information // // and an 8-bit BitmapAlpha.bmp that contains the translucency: // Bitmap myBmp; myBmp.Load( "gfx/BitmapColor.bmp", "gfx/BitmapAlpha.bmp" ); Other functions of the class Bitmap
Questions about Load? Click here. |