diff --git a/SDL2pp/Surface.cc b/SDL2pp/Surface.cc index 4400114..5aa6434 100644 --- a/SDL2pp/Surface.cc +++ b/SDL2pp/Surface.cc @@ -145,6 +145,13 @@ SDL_BlendMode Surface::GetBlendMode() const { return blendMode; } +Color Surface::GetColorAndAlphaMod() const { + Color color; + GetColorMod(color.r, color.g, color.b); + color.SetAlpha(GetAlphaMod()); + return color; +} + void Surface::GetColorMod(Uint8& r, Uint8& g, Uint8& b) const { if (SDL_GetSurfaceColorMod(surface_, &r, &g, &b) != 0) throw Exception("SDL_GetSurfaceColorMod"); @@ -180,6 +187,10 @@ Surface& Surface::SetColorMod(Uint8 r, Uint8 g, Uint8 b) { return *this; } +Surface& Surface::SetColorAndAlphaMod(const Color color) { + return SetColorMod(color.r, color.g, color.b).SetAlphaMod(color.a); +} + Surface& Surface::SetRLE(bool flag) { if (SDL_SetSurfaceRLE(surface_, flag ? 1 : 0) != 0) throw Exception("SDL_SetSurfaceRLE"); diff --git a/SDL2pp/Surface.hh b/SDL2pp/Surface.hh index c3930e6..3b18bc5 100644 --- a/SDL2pp/Surface.hh +++ b/SDL2pp/Surface.hh @@ -30,6 +30,7 @@ #include #include #include +#include struct SDL_Surface; struct SDL_PixelFormat; @@ -390,6 +391,18 @@ public: //////////////////////////////////////////////////////////// SDL_BlendMode GetBlendMode() const; + //////////////////////////////////////////////////////////// + /// \brief Get the additional color value multiplied into blit operations + /// + /// \return Color object with the values used to do blit operations + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_GetSurfaceColorMod + /// + //////////////////////////////////////////////////////////// + Color GetColorAndAlphaMod() const; + //////////////////////////////////////////////////////////// /// \brief Get the additional color value multiplied into blit operations /// @@ -477,6 +490,20 @@ public: //////////////////////////////////////////////////////////// Surface& SetColorMod(Uint8 r = 255, Uint8 g = 255, Uint8 b = 255); + //////////////////////////////////////////////////////////// + /// \brief Set an additional color value multiplied into blit operations + /// + /// \param[in] color Color to be multiplied into blit operations + /// + /// \returns Reference to self + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_SetSurfaceColorMod + /// + //////////////////////////////////////////////////////////// + Surface& SetColorAndAlphaMod(const Color color); + //////////////////////////////////////////////////////////// /// \brief Set the RLE acceleration hint for a surface ///