mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-09-11 00:06:20 -04:00
Added Surface constructor based on SDL_CreateRGBSurfaceWithFormatFrom (issue #80)
This commit is contained in:
parent
a668a2dbd5
commit
5cf39322a6
@ -56,6 +56,11 @@ Surface::Surface(Uint32 flags, int width, int height, int depth, Uint32 format)
|
|||||||
if ((surface_ = SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format)) == nullptr)
|
if ((surface_ = SDL_CreateRGBSurfaceWithFormat(flags, width, height, depth, format)) == nullptr)
|
||||||
throw Exception("SDL_CreateRGBSurfaceWithFormat");
|
throw Exception("SDL_CreateRGBSurfaceWithFormat");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Surface::Surface(void* pixels, int width, int height, int depth, int pitch, Uint32 format) {
|
||||||
|
if ((surface_ = SDL_CreateRGBSurfaceWithFormatFrom(pixels, width, height, depth, pitch, format)) == nullptr)
|
||||||
|
throw Exception("SDL_CreateRGBSurfaceWithFormatFrom");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL2PP_WITH_IMAGE
|
#ifdef SDL2PP_WITH_IMAGE
|
||||||
|
@ -228,6 +228,23 @@ public:
|
|||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Surface(Uint32 flags, int width, int height, int depth, Uint32 format);
|
Surface(Uint32 flags, int width, int height, int depth, Uint32 format);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Create RGB surface with the given format from the given pixel data
|
||||||
|
///
|
||||||
|
/// \param[in] pixels The pixel data to create the surface from
|
||||||
|
/// \param[in] width Width of the surface
|
||||||
|
/// \param[in] height Height of the surface
|
||||||
|
/// \param[in] depth Depth of the surface
|
||||||
|
/// \param[in] pitch The length of a row of pixels in bytes
|
||||||
|
/// \param[in] format The pixel format of the surface
|
||||||
|
///
|
||||||
|
/// \throws SDL2pp::Exception
|
||||||
|
///
|
||||||
|
/// \see https://wiki.libsdl.org/SDL_CreateRGBSurfaceWithFormat
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
Surface(void* pixels, int width, int height, int depth, int pitch, Uint32 format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL2PP_WITH_IMAGE
|
#ifdef SDL2PP_WITH_IMAGE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user