29#ifndef NOMLIB_SDL2_IMAGE_HEADERS
30#define NOMLIB_SDL2_IMAGE_HEADERS
38#include "nomlib/config.hpp"
39#include "nomlib/math/Color4.hpp"
40#include "nomlib/math/Point2.hpp"
41#include "nomlib/math/Size2.hpp"
42#include "nomlib/math/Rect.hpp"
50 typedef Image* RawPtr;
51 typedef std::shared_ptr<Image> SharedPtr;
71 SDL_Surface*
clone (
void )
const;
74 SDL_Surface*
image (
void )
const;
76 SDL_Texture* texture (
void )
const;
89 bool initialize (
void* pixels, int32 width, int32 height,
90 int bits_per_pixel, uint16 pitch,
91 uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask
97 bool initialize ( int32 width, int32 height,
int bits_per_pixel, uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask );
111 bool create(
const Size2i&
size, uint32 pixel_format );
122 int32 width (
void )
const;
123 int32 height (
void )
const;
124 void* pixels (
void )
const;
125 uint16 pitch (
void )
const;
127 uint8 bits_per_pixel (
void )
const;
129 const SDL_PixelFormat* pixel_format (
void )
const;
143 const IntRect bounds (
void )
const;
159 const Point2i position (
void )
const;
161 void set_bounds (
const IntRect& bounds );
165 bool load(
const std::string& filename, uint32 pixel_format = SDL_PIXELFORMAT_ARGB8888 );
177 const std::string& ext,
178 uint32 pixel_format = SDL_PIXELFORMAT_ARGB8888 );
185 bool load_bmp (
const std::string& filename, uint32 pixel_format = SDL_PIXELFORMAT_ARGB8888 );
193 bool save_bmp (
const std::string& filename )
const;
201 bool save_png (
const std::string& filename )
const;
258 Color4i
pixel(
const Point2i& pos )
const;
285 bool set_alpha ( uint8 opacity );
287 void set_position (
const Point2i& pos );
292 void draw ( SDL_Surface* destination,
const IntRect& bounds )
const;
SDL_Surface * image(void) const
Obtain the SDL_Surface struct used in this object instance.
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.
uint32 alpha_mask(void) const
Obtain the video surface's alpha mask.
bool set_color_modulation(const Color4i &color)
Set an additional color value multiplied into render copy operations.
const Color4i colorkey(void) const
void draw(SDL_Surface *destination, const IntRect &bounds) const
bool valid(void) const
Is this object initialized? Valid when NOT nullptr.
bool set_colorkey(const Color4i &colorkey, bool flag)
SDL_Surface * clone(void) const
Make a copy of the existing surface.
bool set_blend_mode(const SDL_BlendMode blend)
Set a new blending mode for blitting.
Image & operator=(const Image &other)
Copy assignment constructor.
bool initialize(const Point2i &size)
Create a new memory buffer using the most optimal pixel format detected for your graphics hardware.
bool initialize(SDL_Surface *source)
Initialize a nom::Image from an existing SDL_Surface.
bool initialize(int32 width, int32 height, int bits_per_pixel, uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask)
Image(void)
Default constructor – initializes to sane defaults.
uint32 red_mask(void) const
Obtain the video surface's red alpha mask.
uint32 blue_mask(void) const
Obtain the video surface's blue alpha mask.
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 load_bmp(const std::string &filename, uint32 pixel_format=SDL_PIXELFORMAT_ARGB8888)
const Color4i color_modulation(void) const
Obtain the additional color value multiplied into render copy operations.
std::shared_ptr< SDL_Surface > image_
Container for our image pixels buffer.
bool load(const std::string &filename, uint32 pixel_format=SDL_PIXELFORMAT_ARGB8888)
uint32 green_mask(void) const
Obtain the video surface's green alpha mask.
bool create(const Point2i &size, uint32 pixel_format)
Create a new memory buffer.
const SDL_BlendMode blend_mode(void) const
Obtain the blend mode used for blitting.
bool must_lock() const
Check to see if the video surface needs locking.
bool save_bmp(const std::string &filename) const
Color4i color4i_pixel(int x, int y) const
Read a RGBA pixel from the video surface.
bool initialize(void *pixels, int32 width, int32 height, int bits_per_pixel, uint16 pitch, uint32 Rmask, uint32 Gmask, uint32 Bmask, uint32 Amask)
bool save_png(const std::string &filename) const
uint8 alpha(void) const
Obtain the alpha value of this video surface.
uint32 pixel(int x, int y) const
Read a RGBA pixel from the video surface.
Image(const Image ©)
Copy constructor.
Size2i size() const
Obtain the width and height (in pixels) of the stored bitmap buffer.