You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
607 B
26 lines
607 B
#include "utils/surface_to_png.hpp" |
|
|
|
#include <cstdio> |
|
#include <string> |
|
|
|
#include <SDL.h> |
|
#include <expected.hpp> |
|
|
|
#include "engine/surface.hpp" |
|
|
|
namespace devilution { |
|
|
|
extern "C" int IMG_SavePNG_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst); |
|
|
|
tl::expected<void, std::string> |
|
WriteSurfaceToFilePng(const Surface &buf, SDL_RWops *dst) |
|
{ |
|
if (IMG_SavePNG_RW(buf.surface, dst, /*freedst=*/1) != 0) { |
|
tl::expected<void, std::string> result = tl::make_unexpected(std::string(SDL_GetError())); |
|
SDL_ClearError(); |
|
return result; |
|
} |
|
return {}; |
|
} |
|
|
|
} // namespace devilution
|
|
|