Manages images.
More...
#include <image.h>
|
| Image (std::string filename) |
| Image (unsigned int width, unsigned int height, unsigned int bytes_per_pixel, void *data) |
bool | create_empty (unsigned int width, unsigned int height) |
| Creates an empty image.
|
bool | load (const std::string &filename) |
| Loads a new image file.
|
bool | load (unsigned int width, unsigned int height, unsigned int bytes_per_pixel, void *data) |
| Loads image from a data buffer.
|
bool | save (const std::string &filename) |
| Saves the image as a file.
|
bool | copy_from (const Image &src, int x, int y) |
| Copies an image into the current image.
|
bool | copy_from (const Image &src, SDL_Rect &dst_rect) |
| Copies an image into the current image.
|
bool | copy_from (const Image &src, SDL_Rect &dst_rect, const SDL_Rect &src_rect) |
| Copies an image into the current image.
|
void | vertical_flip () |
| Flips the image along its x-axis.
|
void | horizontal_flip () |
| Flips the image along its y-axis.
|
void | set_color_key (int r, int g, int b, bool enable=true) |
| Sets a color to be transparent.
|
|
static void | add_path (std::string path) |
| Adds a path to the list of paths to be searched for image files.
|
|
unsigned int | width |
| The width of the image surface.
|
unsigned int | height |
| The width of the image surface.
|
unsigned int | bytes_per_pixel |
| The number of bytes that make up a single pixel.
|
void * | data |
| The pixel data.
|
SDL_Surface * | image |
| The image surface.
|
Manages images.
Definition at line 12 of file image.h.
◆ Image() [1/3]
◆ Image() [2/3]
Image::Image |
( |
std::string | filename | ) |
|
- Parameters
-
filename | Path to the image file to load |
Definition at line 16 of file image.cpp.
◆ Image() [3/3]
Image::Image |
( |
unsigned int | width, |
|
|
unsigned int | height, |
|
|
unsigned int | bytes_per_pixel, |
|
|
void * | data ) |
- Parameters
-
width | The width of the image |
height | The height of the image |
bytes_per_pixel | The number of bytes that represent a pixel |
data | A pointer to the buffer data |
Definition at line 31 of file image.cpp.
◆ ~Image()
◆ add_path()
void Image::add_path |
( |
std::string | path | ) |
|
|
static |
Adds a path to the list of paths to be searched for image files.
- Parameters
-
path | The path to add to the list |
- Note
- To avoid duplicates this function first performs a search on existing entries.
Definition at line 374 of file image.cpp.
◆ copy_from() [1/3]
bool Image::copy_from |
( |
const Image & | src, |
|
|
int | x, |
|
|
int | y ) |
Copies an image into the current image.
- Parameters
-
src | The image to be copied |
x | The x coordinate to copy the image to |
y | The y coordinate to copy the image to |
Definition at line 282 of file image.cpp.
◆ copy_from() [2/3]
bool Image::copy_from |
( |
const Image & | src, |
|
|
SDL_Rect & | dst_rect ) |
Copies an image into the current image.
- Parameters
-
src | The image to be copied |
dst_rect | The coordinates to copy the image to |
Definition at line 289 of file image.cpp.
◆ copy_from() [3/3]
bool Image::copy_from |
( |
const Image & | src, |
|
|
SDL_Rect & | dst_rect, |
|
|
const SDL_Rect & | src_rect ) |
Copies an image into the current image.
- Parameters
-
src | The image to be copied |
dst_rect | The coordinates to copy the image to |
src_rect | The part of the image to copy |
Definition at line 307 of file image.cpp.
◆ create_empty()
bool Image::create_empty |
( |
unsigned int | width, |
|
|
unsigned int | height ) |
Creates an empty image.
- Parameters
-
width | The width of the image |
height | The height of the image |
- Returns
- Returns true on success, false otherwise
Definition at line 56 of file image.cpp.
◆ horizontal_flip()
void Image::horizontal_flip |
( |
| ) |
|
Flips the image along its y-axis.
Definition at line 350 of file image.cpp.
◆ load() [1/2]
bool Image::load |
( |
const std::string & | filename | ) |
|
Loads a new image file.
- Parameters
-
filename | Path to the image file to load |
- Returns
- Returns true on success, false otherwise
Definition at line 97 of file image.cpp.
◆ load() [2/2]
bool Image::load |
( |
unsigned int | width, |
|
|
unsigned int | height, |
|
|
unsigned int | bytes_per_pixel, |
|
|
void * | data ) |
Loads image from a data buffer.
- Parameters
-
width | The width of the image |
height | The height of the image |
bytes_per_pixel | The number of bytes that represent a pixel |
data | A pointer to the buffer data |
- Returns
- Returns true on success, false otherwise
- Note
- The image object keeps it's own copy of the data until a new image is loaded
Definition at line 135 of file image.cpp.
◆ save()
bool Image::save |
( |
const std::string & | filename | ) |
|
Saves the image as a file.
- Parameters
-
filename | The path to save the image to |
- Returns
- Returns true on success, false otherwise
Definition at line 205 of file image.cpp.
◆ set_color_key()
void Image::set_color_key |
( |
int | r, |
|
|
int | g, |
|
|
int | b, |
|
|
bool | enable = true ) |
Sets a color to be transparent.
- Parameters
-
r | The red color channel |
g | The green color channel |
b | The blue color channel |
enable | True to enable color key, false to disable it |
Definition at line 370 of file image.cpp.
◆ vertical_flip()
void Image::vertical_flip |
( |
| ) |
|
Flips the image along its x-axis.
Definition at line 330 of file image.cpp.
◆ bytes_per_pixel
unsigned int sgltk::Image::bytes_per_pixel |
The number of bytes that make up a single pixel.
Definition at line 35 of file image.h.
◆ data
The pixel data.
Definition at line 39 of file image.h.
◆ height
unsigned int sgltk::Image::height |
The width of the image surface.
Definition at line 31 of file image.h.
◆ image
SDL_Surface* sgltk::Image::image |
The image surface.
Definition at line 44 of file image.h.
◆ width
unsigned int sgltk::Image::width |
The width of the image surface.
Definition at line 27 of file image.h.
The documentation for this class was generated from the following files:
- /home/fstdb/proj/sgltk_example/sgltk/src/image.h
- /home/fstdb/proj/sgltk_example/sgltk/src/image.cpp