libSDL2pp
C++ bindings/wrapper for SDL2
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
SDL2pp::Surface Class Reference

Image stored in system memory with direct access to pixel data. More...

#include <SDL2pp/Surface.hh>

Classes

class  LockHandle
 SDL2pp::Surface lock. More...
 

Public Member Functions

 Surface (SDL_Surface *surface)
 Construct from existing SDL_Surface structure.
 
 Surface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
 Create RGB surface.
 
 Surface (void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
 Create RGB surface with existing pixel data.
 
 Surface (RWops &rwops)
 Create surface loading it via RWops.
 
 Surface (const std::string &filename)
 Create surface loading it from file.
 
virtual ~Surface ()
 Destructor.
 
 Surface (Surface &&other) noexcept
 Move constructor.
 
Surfaceoperator= (Surface &&other) noexcept
 Move assignment.
 
 Surface (const Surface &)=delete
 Deleted copy constructor.
 
Surfaceoperator= (const Surface &)=delete
 Deleted assignment operator.
 
SDL_Surface * Get () const
 Get pointer to managed SDL_Surface structure.
 
Surface Convert (const SDL_PixelFormat &format)
 Copy an existing surface into a new one that is optimized for blitting to a surface of a specified pixel format.
 
Surface Convert (Uint32 pixel_format)
 Copy an existing surface to a new surface of the specified format.
 
void Blit (const Optional< Rect > &srcrect, Surface &dst, const Rect &dstrect)
 Fast surface copy to a destination surface.
 
void BlitScaled (const Optional< Rect > &srcrect, Surface &dst, const Optional< Rect > &dstrect)
 Scaled surface copy to a destination surface.
 
LockHandle Lock ()
 Lock surface for direct pixel access.
 
Rect GetClipRect () const
 Get the clipping rectangle for a surface.
 
Uint32 GetColorKey () const
 Get the color key (transparent pixel) for a surface.
 
Uint8 GetAlphaMod () const
 Get the additional alpha value used in blit operations.
 
SDL_BlendMode GetBlendMode () const
 Get blend mode used for blit operations.
 
Color GetColorAndAlphaMod () const
 Get the additional color value multiplied into blit operations.
 
void GetColorMod (Uint8 &r, Uint8 &g, Uint8 &b) const
 Get the additional color value multiplied into blit operations.
 
SurfaceSetClipRect (const Optional< Rect > &rect=NullOpt)
 Set the clipping rectangle for a surface.
 
SurfaceSetColorKey (bool flag, Uint32 key)
 Set the color key (transparent pixel) in a surface.
 
SurfaceSetAlphaMod (Uint8 alpha=255)
 Set an additional alpha value used in blit operations.
 
SurfaceSetBlendMode (SDL_BlendMode blendMode)
 Set the blend mode used for blit operations.
 
SurfaceSetColorMod (Uint8 r=255, Uint8 g=255, Uint8 b=255)
 Set an additional color value multiplied into blit operations.
 
SurfaceSetColorAndAlphaMod (const Color &color)
 Set an additional color value multiplied into blit operations.
 
SurfaceSetRLE (bool flag)
 Set the RLE acceleration hint for a surface.
 
SurfaceFillRect (const Optional< Rect > &rect, Uint32 color)
 Perform a fast fill of a rectangle with a specific color.
 
SurfaceFillRects (const Rect *rects, int count, Uint32 color)
 Perform a fast fill of a set of rectangles with a specific color.
 
int GetWidth () const
 Get surface width.
 
int GetHeight () const
 Get surface height.
 
Point GetSize () const
 Get surface size.
 
Uint32 GetFormat () const
 Get texture format.
 

Detailed Description

Image stored in system memory with direct access to pixel data.

See also
http://wiki.libsdl.org/SDL_Surface

Constructor & Destructor Documentation

◆ Surface() [1/7]

SDL2pp::Surface::Surface ( SDL_Surface *  surface)
explicit

Construct from existing SDL_Surface structure.

Parameters
[in]surfaceExisting SDL_Surface to manage

◆ Surface() [2/7]

SDL2pp::Surface::Surface ( Uint32  flags,
int  width,
int  height,
int  depth,
Uint32  Rmask,
Uint32  Gmask,
Uint32  Bmask,
Uint32  Amask 
)

Create RGB surface.

Parameters
[in]flagsUnused and should be set to 0
[in]widthWidth of the surface
[in]heightHeight of the surface
[in]depthDepth of the surface in bits
[in]RmaskRed mask for the pixels
[in]GmaskGreen mask for the pixels
[in]BmaskBlue mask for the pixels
[in]AmaskAlpha mask for the pixels
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_CreateRGBSurface

◆ Surface() [3/7]

SDL2pp::Surface::Surface ( void *  pixels,
int  width,
int  height,
int  depth,
int  pitch,
Uint32  Rmask,
Uint32  Gmask,
Uint32  Bmask,
Uint32  Amask 
)

Create RGB surface with existing pixel data.

Parameters
[in]pixelsPointer to existing pixel data
[in]widthWidth of the surface
[in]heightHeight of the surface
[in]depthDepth of the surface in bits
[in]pitchNumber of bytes in a row of pixel data, including padding between lines
[in]RmaskRed mask for the pixels
[in]GmaskGreen mask for the pixels
[in]BmaskBlue mask for the pixels
[in]AmaskAlpha mask for the pixels
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_CreateRGBSurfaceFrom

◆ Surface() [4/7]

SDL2pp::Surface::Surface ( RWops rwops)
explicit

Create surface loading it via RWops.

Parameters
[in]rwopsRWops used to access an image file
Exceptions
SDL2pp::Exception

◆ Surface() [5/7]

SDL2pp::Surface::Surface ( const std::string &  filename)
explicit

Create surface loading it from file.

Parameters
[in]filenamePath to an image file
Exceptions
SDL2pp::Exception

◆ ~Surface()

SDL2pp::Surface::~Surface ( )
virtual

◆ Surface() [6/7]

SDL2pp::Surface::Surface ( Surface &&  other)
noexcept

Move constructor.

Parameters
[in]otherSDL2pp::Surface object to move data from

◆ Surface() [7/7]

SDL2pp::Surface::Surface ( const Surface )
delete

Deleted copy constructor.

This class is not copyable

Member Function Documentation

◆ Blit()

void SDL2pp::Surface::Blit ( const Optional< Rect > &  srcrect,
Surface dst,
const Rect dstrect 
)

Fast surface copy to a destination surface.

Parameters
[in]srcrectRectangle to be copied, or NullOpt to copy the entire surface
[in]dstBlit target surface
[in]dstrectRectangle that is copied into
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_BlitSurface

◆ BlitScaled()

void SDL2pp::Surface::BlitScaled ( const Optional< Rect > &  srcrect,
Surface dst,
const Optional< Rect > &  dstrect 
)

Scaled surface copy to a destination surface.

Parameters
[in]srcrectRectangle to be copied, or NullOpt to copy the entire surface
[in]dstBlit target surface
[in]dstrectRectangle that is copied into, or NullOpt to copy into entire surface
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_BlitScaled

◆ Convert() [1/2]

Surface SDL2pp::Surface::Convert ( const SDL_PixelFormat &  format)

Copy an existing surface into a new one that is optimized for blitting to a surface of a specified pixel format.

Parameters
[in]formatSDL_PixelFormat structure that the new surface is optimized for
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_ConvertSurface

◆ Convert() [2/2]

Surface SDL2pp::Surface::Convert ( Uint32  pixel_format)

Copy an existing surface to a new surface of the specified format.

Parameters
[in]pixel_formatOne of the enumerated values in SDL_PixelFormatEnum
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_PixelFormatEnum
http://wiki.libsdl.org/SDL_ConvertSurfaceFormat

◆ FillRect()

Surface & SDL2pp::Surface::FillRect ( const Optional< Rect > &  rect,
Uint32  color 
)

Perform a fast fill of a rectangle with a specific color.

Parameters
[in]rectRectangle to fill, or NullOpt to fill the entire surface
[in]colorColor to fill with
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_FillRect

◆ FillRects()

Surface & SDL2pp::Surface::FillRects ( const Rect rects,
int  count,
Uint32  color 
)

Perform a fast fill of a set of rectangles with a specific color.

Parameters
[in]rectsArray rectangles to be filled
[in]countNumber of rectangles in the array
[in]colorColor to fill with
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_FillRects

◆ Get()

SDL_Surface * SDL2pp::Surface::Get ( ) const

Get pointer to managed SDL_Surface structure.

Returns
Pointer to managed SDL_Surface structure

◆ GetAlphaMod()

Uint8 SDL2pp::Surface::GetAlphaMod ( ) const

Get the additional alpha value used in blit operations.

Returns
Current alpha value
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetSurfaceAlphaMod

◆ GetBlendMode()

SDL_BlendMode SDL2pp::Surface::GetBlendMode ( ) const

Get blend mode used for blit operations.

Returns
Current SDL_BlendMode
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetSurfaceBlendMode

◆ GetClipRect()

Rect SDL2pp::Surface::GetClipRect ( ) const

Get the clipping rectangle for a surface.

Returns
Rect filled in with the clipping rectangle for the surface
See also
http://wiki.libsdl.org/SDL_GetClipRect

◆ GetColorAndAlphaMod()

Color SDL2pp::Surface::GetColorAndAlphaMod ( ) const

Get the additional color value multiplied into blit operations.

Returns
Color object with the values used to do blit operations
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetSurfaceAlphaMod
http://wiki.libsdl.org/SDL_GetSurfaceColorMod

◆ GetColorKey()

Uint32 SDL2pp::Surface::GetColorKey ( ) const

Get the color key (transparent pixel) for a surface.

Returns
Transparent pixel value
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetColorKey

◆ GetColorMod()

void SDL2pp::Surface::GetColorMod ( Uint8 &  r,
Uint8 &  g,
Uint8 &  b 
) const

Get the additional color value multiplied into blit operations.

Parameters
[out]rVariable to be filled in with the current red color value
[out]gVariable to be filled in with the current green color value
[out]bVariable to be filled in with the current blue color value
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_GetSurfaceColorMod

◆ GetFormat()

Uint32 SDL2pp::Surface::GetFormat ( ) const

◆ GetHeight()

int SDL2pp::Surface::GetHeight ( ) const

Get surface height.

Returns
Surface height in pixels

◆ GetSize()

Point SDL2pp::Surface::GetSize ( ) const

Get surface size.

Returns
SDL2pp::Point representing surface dimensions in pixels

◆ GetWidth()

int SDL2pp::Surface::GetWidth ( ) const

Get surface width.

Returns
Surface width in pixels

◆ Lock()

Surface::LockHandle SDL2pp::Surface::Lock ( )

Lock surface for direct pixel access.

Returns
Lock handle used to access pixel data and to control lock lifetime
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_LockSurface

◆ operator=() [1/2]

Surface & SDL2pp::Surface::operator= ( const Surface )
delete

Deleted assignment operator.

This class is not copyable

◆ operator=() [2/2]

Surface & SDL2pp::Surface::operator= ( Surface &&  other)
noexcept

Move assignment.

Parameters
[in]otherSDL2pp::Surface object to move data from
Returns
Reference to self

◆ SetAlphaMod()

Surface & SDL2pp::Surface::SetAlphaMod ( Uint8  alpha = 255)

Set an additional alpha value used in blit operations.

Parameters
[in]alphaAlpha value multiplied into blit operations
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetSurfaceAlphaMod

◆ SetBlendMode()

Surface & SDL2pp::Surface::SetBlendMode ( SDL_BlendMode  blendMode)

Set the blend mode used for blit operations.

Parameters
[in]blendModeSDL_BlendMode to use for blit blending
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetSurfaceBlendMode

◆ SetClipRect()

Surface & SDL2pp::Surface::SetClipRect ( const Optional< Rect > &  rect = NullOpt)

Set the clipping rectangle for a surface.

Parameters
[in]rectRect representing the clipping rectangle, or NullOpt to disable clipping
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetClipRect

◆ SetColorAndAlphaMod()

Surface & SDL2pp::Surface::SetColorAndAlphaMod ( const Color color)

Set an additional color value multiplied into blit operations.

Parameters
[in]colorColor to be multiplied into blit operations
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetSurfaceAlphaMod
http://wiki.libsdl.org/SDL_SetSurfaceColorMod

◆ SetColorKey()

Surface & SDL2pp::Surface::SetColorKey ( bool  flag,
Uint32  key 
)

Set the color key (transparent pixel) in a surface.

Parameters
[in]flagTrue to enabled color key, false to disable
[in]keyTransparent pixel value
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetColorKey

◆ SetColorMod()

Surface & SDL2pp::Surface::SetColorMod ( Uint8  r = 255,
Uint8  g = 255,
Uint8  b = 255 
)

Set an additional color value multiplied into blit operations.

Parameters
[in]rRed color value multiplied into blit operations
[in]gGreen color value multiplied into blit operations
[in]bBlue color value multiplied into blit operations
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetSurfaceColorMod

◆ SetRLE()

Surface & SDL2pp::Surface::SetRLE ( bool  flag)

Set the RLE acceleration hint for a surface.

Parameters
[in]flagFalse to disable, true to enable RLE acceleration
Returns
Reference to self
Exceptions
SDL2pp::Exception
See also
http://wiki.libsdl.org/SDL_SetSurfaceRLE

The documentation for this class was generated from the following files: