17 #ifndef SDL_UTILS_INCLUDED
18 #define SDL_UTILS_INCLUDED
34 #ifndef SDL_BUTTON_WHEELUP
35 #define SDL_BUTTON_WHEELUP 4
38 #ifndef SDL_BUTTON_WHEELDOWN
39 #define SDL_BUTTON_WHEELDOWN 5
42 #ifndef SDL_BUTTON_WHEELLEFT
43 #define SDL_BUTTON_WHEELLEFT 6
46 #ifndef SDL_BUTTON_WHEELRIGHT
47 #define SDL_BUTTON_WHEELRIGHT 7
66 SDL_FreeSurface(surf);
113 SDL_BlitSurface(src, src_rect, dst, dst_rect);
117 SDL_SetSurfaceBlendMode(screen, SDL_BLENDMODE_NONE);
118 SDL_SetSurfaceBlendMode(dst, SDL_BLENDMODE_NONE);
119 SDL_BlitSurface(screen, screen_rect, dst, dst_rect);
120 SDL_SetSurfaceBlendMode(screen, SDL_BLENDMODE_BLEND);
131 unsigned char a,
unsigned char drop);
165 const surface&
surf,
const unsigned w,
const bool optimize =
true);
184 const surface&
surf,
const unsigned h,
const bool optimize =
true);
354 ,
const bool optimize =
true);
371 int zoom,
int offset,
bool optimize=
true);
418 const SDL_Rect* srcrect,
surface&
dst,
const SDL_Rect* dstrect);
422 bool operator==(
const SDL_Color&
a,
const SDL_Color&
b);
423 bool operator!=(
const SDL_Color&
a,
const SDL_Color&
b);
430 ,
unsigned char green
432 ,
unsigned char alpha = SDL_ALPHA_OPAQUE);
455 const Uint32*
pixels()
const {
return reinterpret_cast<const Uint32*
>(
surface_->pixels); }
519 std::ostream&
operator<<(std::ostream&
s,
const SDL_Rect& rect);
void operator()(SDL_Surface *surf) const
Uint32 get_pixel(const surface &surf, const const_surface_lock &surf_lock, int x, int y)
surface scale_surface_nn(const surface &surf, int w, int h)
Scale a surface using the nearest neighbor algorithm (provided by xBRZ lib)
SDL_Surface * get() const
GLint GLint GLsizei GLsizei GLsizei depth
surface(SDL_Surface *surf)
void blit_surface(const surface &src, const SDL_Rect *srcrect, surface &dst, const SDL_Rect *dstrect)
Replacement for sdl_blit.
surface create_neutral_surface(int w, int h)
surface alpha_to_greyscale(const surface &surf, bool optimize=true)
surface stretch_surface_horizontal(const surface &surf, const unsigned w, const bool optimize=true)
Stretches a surface in the horizontal direction.
surface tile_surface(const surface &surf, int w, int h, bool optimize=true)
Tile a surface.
surface adjust_surface_alpha(const surface &surf, fixed_t amount, bool optimize=true)
surface light_surface(const surface &surf, const surface &lightmap, bool optimize=true)
Light surf using lightmap.
surface wipe_alpha(const surface &surf, bool optimize=true)
bool operator==(const SDL_Color &a, const SDL_Color &b)
surface scale_surface_xbrz(const surface &surf, size_t z)
Scale a surface using xBRZ algorithm.
const Uint32 * pixels() const
scoped_sdl_surface surface_
std::ostream & operator<<(std::ostream &s, const SDL_Rect &rect)
util::scoped_resource< SDL_Surface *, free_sdl_surface > scoped_sdl_surface
surface rotate_90_surface(const surface &surf, bool clockwise, bool optimize=true)
Rotates a surface 90 degrees.
GLint GLint GLint GLint GLint GLint y
surface negative_image(const surface &surf, const int thresholdR, const int thresholdG, const int thresholdB, bool optimize=true)
bool in_mask_surface(const surface &surf, const surface &mask)
Check if a surface fit into a mask.
scoped_resource: class template, functions, helper policies etc. for resource management.
const_surface_lock(const surface &surf)
Uint32 blend_rgba(const surface &surf, unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned char drop)
This method blends a RGBA color.
surface blend_surface(const surface &surf, const double amount, const Uint32 color, const bool optimize=true)
Blends a surface with a color.
static void sdl_add_ref(SDL_Surface *surf)
surface cut_surface(const surface &surf, SDL_Rect const &r)
Cuts a rectangle from a surface.
surface greyscale_image(const surface &surf, bool optimize=true)
surface scale_surface_sharp(const surface &surf, int w, int h, bool optimize=true)
Scale a surface using modified nearest neighbour algorithm.
GLdouble GLdouble GLdouble b
surface blur_alpha_surface(const surface &surf, int depth=1, bool optimize=true)
Cross-fades a surface with alpha channel.
surface shadow_image(const surface &surf, bool optimize=true)
create an heavy shadow of the image, by blurring, increasing alpha and darkening
Compatibility layer for using SDL 1.2 and 2.0.
GLubyte GLubyte GLubyte GLubyte w
GLboolean GLboolean GLboolean GLboolean a
surface swap_channels_image(const surface &surf, channel r, channel g, channel b, channel a, bool optimize=true)
surface & operator=(const surface &o)
surface blur_surface(const surface &surf, int depth=1, bool optimize=true)
Cross-fades a surface.
GLclampf GLclampf GLclampf alpha
SDL_Surface * operator->() const
SDL_Color string_to_color(const std::string &color_string)
Return the color the string represents.
surface mask_surface(const surface &surf, const surface &mask, bool *empty_result=nullptr, const std::string &filename=std::string())
Applies a mask on a surface.
Helper class for pinning SDL surfaces into memory.
Templates and utility-routines for strings and numbers.
resource_type get() const
This function provides explicit access to the resource.
surface adjust_surface_alpha_add(const surface &surf, int amount, bool optimize=true)
const std::string ¶meters float amount
SDL_Color inverse(const SDL_Color &color)
surface sepia_image(const surface &surf, bool optimize=true)
surface brighten_image(const surface &surf, fixed_t amount, bool optimize=true)
SDL_Color create_color(const unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=SDL_ALPHA_OPAQUE)
SDLKey sdl_keysym_from_name(std::string const &keyname)
surface flop_surface(const surface &surf, bool optimize=true)
void put_pixel(const surface &surf, surface_lock &surf_lock, int x, int y, Uint32 pixel)
Helper methods for setting/getting a single pixel in an image.
bool is_neutral(const surface &surf)
Check that the surface is neutral bpp 32.
surface create_optimized_surface(const surface &surf)
surface get_surface_portion(const surface &surf, SDL_Rect &rect)
Get a portion of the screen.
surface adjust_surface_color(const surface &surf, int r, int g, int b, bool optimize=true)
void assign(const resource_type &o)
GLfloat GLfloat GLfloat GLfloat h
GLint GLint GLint GLint GLint x
bool operator<(const surface &a, const surface &b)
GLdouble GLdouble GLdouble r
surface monochrome_image(const surface &surf, const int threshold, bool optimize=true)
surface make_neutral_surface(const surface &surf)
GLint GLint GLint GLint GLint GLint GLsizei GLsizei height
void assign(SDL_Surface *surf)
surface(const surface &o)
clip_rect_setter(const surface &surf, const SDL_Rect *r, bool operate=true)
SDL_Color int_to_color(const Uint32 rgb)
bool operator!=(const SDL_Color &a, const SDL_Color &b)
const SDL_Rect & area() const
surface flip_surface(const surface &surf, bool optimize=true)
void assign(const surface &o)
surface stretch_surface_vertical(const surface &surf, const unsigned h, const bool optimize=true)
Stretches a surface in the vertical direction.
surface submerge_alpha(const surface &surf, int depth, float alpha_base, float alpha_delta, bool optimize=true)
Progressively reduce alpha of bottom part of the surface.
GLint GLint GLint GLint GLint GLint GLsizei width
surface_lock(surface &surf)
void sdl_copy_portion(const surface &screen, SDL_Rect *screen_rect, surface &dst, SDL_Rect *dst_rect)
void sdl_blit(const surface &src, SDL_Rect *src_rect, surface &dst, SDL_Rect *dst_rect)
surface rotate_any_surface(const surface &surf, float angle, int zoom, int offset, bool optimize=true)
Rotates a surface by any degrees.
surface scale_surface(const surface &surf, int w, int h, bool optimize)
Scale a surface.
surface rotate_180_surface(const surface &surf, bool optimize=true)
Rotates a surface 180 degrees.
void draw_centered_on_background(surface surf, const SDL_Rect &rect, const SDL_Color &color, surface target)
GLsizei const GLcharARB ** string
SDL_Rect get_non_transparent_portion(const surface &surf)
surface create_compatible_surface(const surface &surf, int width=-1, int height=-1)
surface recolor_image(surface surf, const std::map< Uint32, Uint32 > &map_rgb, bool optimize=true)
Recolors a surface using a map with source and converted palette values.