OXYGENHUB
◆ main openmsx / src / video / PNG.hh
1.0 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef PNG_HH
2
#define PNG_HH
3
4
#include "SDLSurfacePtr.hh"
5
6
#include <cstdint>
7
#include <span>
8
#include <string>
9
10
/** Utility functions to hide the complexity of saving to a PNG file.
11
  */
12
namespace openmsx::PNG {
13
	/** Load the given PNG file in a SDL_Surface.
14
	 * This SDL_Surface is either 24bpp or 32bpp, depending on whether the
15
	 * PNG file had an alpha layer. But it's possible to force a 32bpp
16
	 * surface. The surface will use RGB(A) or BGR(A) format depending on
17
	 * the current display format.
18
	 */
19
	[[nodiscard]] SDLSurfacePtr load(const std::string& filename, bool want32bpp);
20
21
	void saveRGBA(size_t width, std::span<const uint32_t*> rowPointers,
22
	              const std::string& filename);
23
	/** Save an RGB (24bpp) buffer as a PNG file. Each row is width*3 bytes. */
24
	void saveRGB(size_t width, std::span<const uint8_t*> rowPointers,
25
	       const std::string& filename);
26
	void saveGrayscale(size_t width, std::span<const uint8_t*> rowPointers,
27
	                   const std::string& filename);
28
29
} // namespace openmsx::PNG
30
31
#endif // PNG_HH