ManaPlus
Public Member Functions
SdlScreenshotHelper Class Reference

#include <sdlscreenshothelper.h>

Inheritance diagram for SdlScreenshotHelper:
ScreenshotHelper

Public Member Functions

 SdlScreenshotHelper ()
 
 ~SdlScreenshotHelper ()
 
void prepare ()
 
SDL_Surface * getScreenshot ()
 
- Public Member Functions inherited from ScreenshotHelper
 ScreenshotHelper ()
 
virtual ~ScreenshotHelper ()
 

Detailed Description

Definition at line 31 of file sdlscreenshothelper.h.

Constructor & Destructor Documentation

◆ SdlScreenshotHelper()

SdlScreenshotHelper::SdlScreenshotHelper ( )

Definition at line 39 of file sdlscreenshothelper.cpp.

39  :
41 {
42 }

◆ ~SdlScreenshotHelper()

SdlScreenshotHelper::~SdlScreenshotHelper ( )

Definition at line 44 of file sdlscreenshothelper.cpp.

45 {
46 }

Member Function Documentation

◆ getScreenshot()

SDL_Surface * SdlScreenshotHelper::getScreenshot ( )
virtual

< Surface is in system memory

Implements ScreenshotHelper.

Definition at line 52 of file sdlscreenshothelper.cpp.

53 {
54  if (mainGraphics == nullptr)
55  return nullptr;
56 
57 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
58  const int rmask = 0xff000000;
59  const int gmask = 0x00ff0000;
60  const int bmask = 0x0000ff00;
61 #else // SDL_BYTEORDER == SDL_BIG_ENDIAN
62 
63  const int rmask = 0x000000ff;
64  const int gmask = 0x0000ff00;
65  const int bmask = 0x00ff0000;
66 #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
67 
68  const int amask = 0x00000000;
69 
70  SDL_Surface *const screenshot = MSDL_CreateRGBSurface(SDL_SWSURFACE,
72  24,
73  rmask, gmask, bmask, amask);
74 
75 #ifndef USE_SDL2
76  if (screenshot != nullptr)
77  SDL_BlitSurface(mainGraphics->mWindow, nullptr, screenshot, nullptr);
78 #endif // USE_SDL2
79 
80  return screenshot;
81 }
int mWidth
Definition: graphics.h:484
SDL_Surface * mWindow
Definition: graphics.h:523
int mHeight
Definition: graphics.h:485
#define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a)
Definition: debug.h:55
Graphics * mainGraphics
Definition: graphics.cpp:109
bool screenshot(InputEvent &event)
Definition: actions.cpp:51

References mainGraphics, Graphics::mHeight, MSDL_CreateRGBSurface, Graphics::mWidth, Graphics::mWindow, and Actions::screenshot().

◆ prepare()

void SdlScreenshotHelper::prepare ( )
virtual

Implements ScreenshotHelper.

Definition at line 48 of file sdlscreenshothelper.cpp.

49 {
50 }

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