cImage Surface

This commit is contained in:
2018-06-30 02:33:48 -04:00
parent 269cbf8604
commit 93a6e9ccad
14 changed files with 120 additions and 36 deletions
@@ -112,16 +112,9 @@ void cRenderer::RenderDrawRect( const SDL_Rect& rect, SDL_Texture* dst /*= nullp
void cRenderer::ScreenShot( const cString& filename, const cString& dir /*= ""*/ )
{
SDL_Surface* infoSurface = SDL_GetWindowSurface(VideoEngine::cVideo::Inst().getWindow());
if (infoSurface == nullptr)
cUtility::Inst().Message("Failed to create info surface from window.\n", __AT__, cUtility::eTypeSDL::SDL);
else {
SaveSurface(infoSurface, filename, dir);
SDL_FreeSurface(infoSurface);
infoSurface = NULL;
}
/*SDL_Surface* saveSurface = NewSurface();
SDL_Surface* saveSurface = NewSurface();
if (infoSurface == NULL) {
if (infoSurface == nullptr) {
cUtility::Inst().Message("Failed to create info surface from window.\n", __AT__, cUtility::eTypeSDL::SDL);
} else {
if (SDL_RenderReadPixels(mp_renderer, &infoSurface->clip_rect, infoSurface->format->format, saveSurface->pixels, infoSurface->w * infoSurface->format->BytesPerPixel) != 0)
@@ -129,10 +122,10 @@ void cRenderer::ScreenShot( const cString& filename, const cString& dir /*= ""*/
else
SaveSurface(saveSurface, filename, dir);
SDL_FreeSurface(infoSurface);
infoSurface = NULL;
infoSurface = nullptr;
}
SDL_FreeSurface(saveSurface);
saveSurface = NULL;*/
saveSurface = nullptr;
}
@@ -157,8 +150,7 @@ void cRenderer::SaveTexture( SDL_Texture* texture, const cString& fileName, cons
SDL_Texture* cRenderer::SurfaceToTexture( SDL_Surface* surface )
{
SDL_Texture* rtn = nullptr;
rtn = SDL_CreateTextureFromSurface( mp_renderer, surface );
SDL_Texture* rtn = SDL_CreateTextureFromSurface( mp_renderer, surface );
if ( rtn == nullptr)
cUtility::Inst().Message("Unable to create Texture. SDL_CreateTextureFromSurface():", __AT__, cUtility::eTypeSDL::SDL);
@@ -242,7 +234,7 @@ SDL_Surface* cRenderer::NewSurface( long int width /*= -1*/, long int height /*=
if (height < 0)
height = cVideo::Inst().getHeight();
SDL_Surface* rtn = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), width, height, cVideo::Inst().getColour(), cVideo::Inst().getRmask(), cVideo::Inst().getGmask(), cVideo::Inst().getBmask(), cVideo::Inst().getAmask());
SDL_Surface* rtn = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), width, height, cVideo::Inst().getColourDepth(), cVideo::Inst().getRmask(), cVideo::Inst().getGmask(), cVideo::Inst().getBmask(), cVideo::Inst().getAmask());
if (rtn == nullptr)
cUtility::Inst().Message("Unable to create surface. SDL_CreateRGBSurface():", __AT__, cUtility::eTypeSDL::SDL);