![]() |
nomlib
|
Bitmap storage container. More...
#include <Image.hpp>
Public Types | |
| typedef Image * | RawPtr |
| typedef std::shared_ptr< Image > | SharedPtr |
Public Member Functions | |
| Image (void) | |
| Default constructor – initializes to sane defaults. | |
| ~Image (void) | |
| Destructor. | |
| Image (const Image ©) | |
| Copy constructor. | |
| Image & | operator= (const Image &other) |
| Copy assignment constructor. | |
| SDL_Surface * | clone (void) const |
| Make a copy of the existing surface. | |
| SDL_Surface * | image (void) const |
| Obtain the SDL_Surface struct used in this object instance. | |
| SDL_Texture * | texture (void) const |
| bool | valid (void) const |
| Is this object initialized? Valid when NOT nullptr. | |
| bool | initialize (void *pixels, int32 width, int32 height, int bits_per_pixel, uint16 pitch, uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask) |
| bool | initialize (int32 width, int32 height, int bits_per_pixel, uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask) |
| bool | initialize (SDL_Surface *source) |
| Initialize a nom::Image from an existing SDL_Surface. | |
| bool | create (const Point2i &size, uint32 pixel_format) |
| Create a new memory buffer. | |
| bool | create (const Size2i &size, uint32 pixel_format) |
| bool | initialize (const Point2i &size) |
| Create a new memory buffer using the most optimal pixel format detected for your graphics hardware. | |
| int32 | width (void) const |
| int32 | height (void) const |
| void * | pixels (void) const |
| uint16 | pitch (void) const |
| uint8 | bits_per_pixel (void) const |
| const SDL_PixelFormat * | pixel_format (void) const |
| uint32 | red_mask (void) const |
| Obtain the video surface's red alpha mask. | |
| uint32 | green_mask (void) const |
| Obtain the video surface's green alpha mask. | |
| uint32 | blue_mask (void) const |
| Obtain the video surface's blue alpha mask. | |
| uint32 | alpha_mask (void) const |
| Obtain the video surface's alpha mask. | |
| const IntRect | bounds (void) const |
| bool | must_lock () const |
| Check to see if the video surface needs locking. | |
| bool | locked (void) const |
| uint8 | alpha (void) const |
| Obtain the alpha value of this video surface. | |
| const Point2i | position (void) const |
| void | set_bounds (const IntRect &bounds) |
| bool | load (const std::string &filename, uint32 pixel_format=SDL_PIXELFORMAT_ARGB8888) |
| bool | load_memory (const char *buffer, int buffer_size, const std::string &ext, uint32 pixel_format=SDL_PIXELFORMAT_ARGB8888) |
| Load an image surface from a memory source. | |
| bool | load_bmp (const std::string &filename, uint32 pixel_format=SDL_PIXELFORMAT_ARGB8888) |
| bool | save_bmp (const std::string &filename) const |
| bool | save_png (const std::string &filename) const |
| Size2i | size () const |
| Obtain the width and height (in pixels) of the stored bitmap buffer. | |
| const Color4i | colorkey (void) const |
| const SDL_BlendMode | blend_mode (void) const |
| Obtain the blend mode used for blitting. | |
| const Color4i | color_modulation (void) const |
| Obtain the additional color value multiplied into render copy operations. | |
| bool | set_colorkey (const Color4i &colorkey, bool flag) |
| bool | RLE (bool flag) |
| uint32 | pixel (int x, int y) const |
| Read a RGBA pixel from the video surface. | |
| Color4i | color4i_pixel (int x, int y) const |
| Read a RGBA pixel from the video surface. | |
| Color4i | pixel (const Point2i &pos) const |
| Read a RGBA pixel from the video surface. | |
| void | set_pixel (int x, int y, const Color4i &color) |
| Blit a RGBA pixel onto the video surface. | |
| bool | set_blend_mode (const SDL_BlendMode blend) |
| Set a new blending mode for blitting. | |
| bool | lock () const |
| void | unlock (void) const |
| bool | set_alpha (uint8 opacity) |
| void | set_position (const Point2i &pos) |
| void | draw (SDL_Surface *destination, const IntRect &bounds) const |
| bool | set_color_modulation (const Color4i &color) |
| Set an additional color value multiplied into render copy operations. | |
Private Attributes | |
| std::shared_ptr< SDL_Surface > | image_ |
| Container for our image pixels buffer. | |
| Point2i | position_ |
| IntRect | bounds_ |
| nom::Image::~Image | ( | void | ) |
Destructor.
| SDL_Surface * nom::Image::clone | ( | void | ) | const |
Make a copy of the existing surface.
| Color4i nom::Image::color4i_pixel | ( | int | x, |
| int | y ) const |
Read a RGBA pixel from the video surface.
| const Color4i nom::Image::color_modulation | ( | void | ) | const |
Obtain the additional color value multiplied into render copy operations.
| const Color4i nom::Image::colorkey | ( | void | ) | const |
Obtain the set color key for this image
| bool nom::Image::create | ( | const Point2i & | size, |
| uint32 | pixel_format ) |
Create a new memory buffer.
| size | Point2i initialized with the width & height in pixels |
| pixel_format | Pixel format to use for the memory buffer. |
| void nom::Image::draw | ( | SDL_Surface * | destination, |
| const IntRect & | bounds ) const |
Render a video surface
| bool nom::Image::initialize | ( | const Point2i & | size | ) |
Create a new memory buffer using the most optimal pixel format detected for your graphics hardware.
| size | Point2i initialized with the width & height in pixels |
| bool nom::Image::initialize | ( | int32 | width, |
| int32 | height, | ||
| int | bits_per_pixel, | ||
| uint32 | Rmask, | ||
| uint32 | Gmask, | ||
| uint32 | Bmask, | ||
| uint32 | Amask ) |
Constructor variant for creating a fresh, empty video surface. You should be sure to read over the details gory details scattered throughout the documentation for SDL.
| bool nom::Image::initialize | ( | SDL_Surface * | source | ) |
Initialize a nom::Image from an existing SDL_Surface.
| source | Existing SDL_Surface structure |
| bool nom::Image::initialize | ( | void * | pixels, |
| int32 | width, | ||
| int32 | height, | ||
| int | bits_per_pixel, | ||
| uint16 | pitch, | ||
| uint32 | Rmask, | ||
| uint32 | Gmask, | ||
| uint32 | Bmask, | ||
| uint32 | Amask ) |
Initialize an image surface using the data from an existing pixel buffer (from a SDL_Surface).
| pixels | Typically a void pointer cast to nom::uint16 or nom::uint32 |
| bits_per_pixel | Bits per pixel |
| bool nom::Image::load | ( | const std::string & | filename, |
| uint32 | pixel_format = SDL_PIXELFORMAT_ARGB8888 ) |
Supports every file type that the libSDL_image extension has been compiled with
| bool nom::Image::load_bmp | ( | const std::string & | filename, |
| uint32 | pixel_format = SDL_PIXELFORMAT_ARGB8888 ) |
Uses SDL's built-in BMP file loader; no alpha channeling support ... perfect for setting window icons!
(I have yet to find success using IMG_Load to load an ordinary bitmap file, whereas SDL_LoadBMP does load fine).
| bool nom::Image::load_memory | ( | const char * | buffer, |
| int | buffer_size, | ||
| const std::string & | ext, | ||
| uint32 | pixel_format = SDL_PIXELFORMAT_ARGB8888 ) |
Load an image surface from a memory source.
| buffer | The input buffer contents. |
| buffer_size | The integral size of the image data. |
| ext | The file extension of the image data. |
| pixel_format | The pixel format of the image data. |
| bool nom::Image::lock | ( | ) | const |
Lock the video surface; this must be done before you attempt to write directly to video memory (pixel manipulation).
| bool nom::Image::locked | ( | void | ) | const |
Obtain the locked status of the video surface memory
| Color4i nom::Image::pixel | ( | const Point2i & | pos | ) | const |
Read a RGBA pixel from the video surface.
| uint32 nom::Image::pixel | ( | int | x, |
| int | y ) const |
Read a RGBA pixel from the video surface.
| bool nom::Image::RLE | ( | bool | flag | ) |
Set RLE acceleration for this image
If enabled, color keying and alpha blending blits are much faster, but at the cost of requiring surface locking before directly accessing pixels.
| TRUE | to enable RLE acceleration; FALSE to disable |
| bool nom::Image::save_bmp | ( | const std::string & | filename | ) | const |
Save a screen shot of this image surface as an uncompressed BMP file
| filename | Output filename path |
| bool nom::Image::save_png | ( | const std::string & | filename | ) | const |
Save a screen shot as a Portable Network Graphics (PNG) file.
| filename | Output filename path |
| bool nom::Image::set_color_modulation | ( | const Color4i & | color | ) |
Set an additional color value multiplied into render copy operations.
| nom::Color4i | red, green & blue values multiplied into color operations |
| bool nom::Image::set_colorkey | ( | const Color4i & | colorkey, |
| bool | flag ) |
Set a new color key on the image loaded into memory.
| colorkey | Pixel color to mark transparent |
| flag | TRUE to enable color key; FALSE to disable color key |
| void nom::Image::set_pixel | ( | int | x, |
| int | y, | ||
| const Color4i & | color ) |
Blit a RGBA pixel onto the video surface.
| void nom::Image::unlock | ( | void | ) | const |
Unlocks the video surface; this must be done after you are finished writing to the video buffer. During the time that the video surface is locked, no updates (think: rendering) outside of your local access can occur until the surfaces affected by the lock are relinquished.
|
private |