Skip to content

Commit

Permalink
Tidy up the screenshot functionality by making the write_png function…
Browse files Browse the repository at this point in the history
… hidden.
  • Loading branch information
JonBooth78 committed Jan 8, 2024
1 parent 2ac462c commit 987cc11
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/PngWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <SDL_image.h>

namespace {
void write_png(FileSystem::FileSourceFS &fs, const std::string &path, const Uint8 *bytes, int width, int height, int stride, int bytes_per_pixel, bool strip_alpha)
{
// Set up the pixel format color masks for RGB(A) byte arrays.
Expand Down Expand Up @@ -39,7 +40,6 @@ void write_png(FileSystem::FileSourceFS &fs, const std::string &path, const Uint
}

// create a surface
//SDL_Surface *surface = SDL_CreateRGBSurfaceFrom((void*)bytes, width, height, bytes_per_pixel * 8, width * bytes_per_pixel, rmask, gmask, bmask, amask);
SDL_Surface *surface = SDL_CreateRGBSurface(0, width, height, dest_bpp * 8, rmask, gmask, bmask, amask);

// flip the image vertically and copy to destination surface
Expand Down Expand Up @@ -85,6 +85,7 @@ void write_png(FileSystem::FileSourceFS &fs, const std::string &path, const Uint
SDL_FreeSurface(surface);
surface = nullptr;
}
} //namespace

void write_screenshot(const Graphics::ScreendumpState &sd, const char *destFile)
{
Expand Down
7 changes: 0 additions & 7 deletions src/PngWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@
#include <SDL_stdinc.h>
#include <string>

namespace FileSystem {
class FileSourceFS;
}

namespace Graphics {
struct ScreendumpState;
}

// stride is in bytes (bytes per row)
void write_png(FileSystem::FileSourceFS &fs, const std::string &path, const Uint8 *bytes, int width, int height, int stride, int bytes_per_pixel, bool strip_alpha = false);

void write_screenshot(const Graphics::ScreendumpState &sd, const char *destFile);

#endif

0 comments on commit 987cc11

Please sign in to comment.