e2d::graphics::ImageData Class Reference
List of all members.
Detailed Description
This class controls the image's raw data. For a more specialized class, see
Image.
|
Public Member Functions |
void | Blit (SDL_Surface *destination, Rect *position, Rect *part=NULL) |
| Blits the image to destination.
|
SDL_Surface * | GetSurface (void) |
| Returns a pointer to the image's surface.
|
void | Load (const char *filename) |
| Loads the image from a file.
|
void | Optimize (void) |
| Optimizes the image according to the framebuffer settings.
|
void | SetTransparent (Color color, bool rle_enable=true) |
| Sets a transparent color (enables colorkey).
|
Member Function Documentation
void e2d::graphics::ImageData::Blit |
( |
SDL_Surface * |
destination, |
|
|
Rect * |
position, |
|
|
Rect * |
part = NULL | |
|
) |
| | |
Blits the loaded image to the destination.
- Parameters:
-
| destination | Pointer to an SDL_Surface where the image will be blitted (may be the Video::framebuffer or another image's surface). |
| position | position of the destination where the image will be blitted. |
| part | If you want only part of this image to be blitted, set a Rect with sizes smaller than this image and pass it as a parameter here. The reference point (0,0) is the upper-left corner of this image. |
SDL_Surface * e2d::graphics::ImageData::GetSurface |
( |
void |
|
) |
|
If you want to blit another image into this one, you can get its surface and pass it as a parameter to the other image's Blit() method.
- Returns:
- Pointer to this image's surface (SDL_Surface is part of SDL).
void e2d::graphics::ImageData::Load |
( |
const char * |
filename |
) |
|
Loads an image file. Refer to the SDL_image documentation for file types supported. (As the time of this document's writing, these file types were: BMP, PNM (PPM/PGM/PBM), XPM, LBM, PCX, GIF, JPEG, PNG, TGA, and TIFF). After loading, the image's W and H attributes will be set to the image's width and height, in pixels.
- Parameters:
-
| filename | Path to the image file. |
- Exceptions:
-
void e2d::graphics::ImageData::Optimize |
( |
void |
|
) |
|
After video has been initialized (Video::Init), and after you have an image file loaded, call this function to optimize blitting of this image into the framebuffer, by placing this image directly into video memory and adjusting its pixel format to the same format as the framebuffer. This only needs to be called once after image loading (or framebuffer re-initializing). Remember to call it AFTER SetTransparent() to take advantage of hardware accelerated colorkeying (RLE).
- Exceptions:
-
| e2d::core::Exception | if the optimization did not succeed and the image got screwed up because of this. |
void e2d::graphics::ImageData::SetTransparent |
( |
Color |
color, |
|
|
bool |
rle_enable = true | |
|
) |
| | |
Setting a transparent color means that, whenever a pixel of that color is found on the image, it will not be blitted anywhere. Don't mistake transparency with alpha-blending.
- Parameters:
-
| color | The color to consider as being transparent. |
| rle_enable | Enables RLE (refer to the SDL documentation for more details). |
- Exceptions:
-