libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
loadpng.hpp
Go to the documentation of this file.
1/**
2 * @file loadpng.hpp
3 * @brief PNG image loading and saving utilities via SDL.
4 */
5#ifndef __LOADPNG_H__
6#define __LOADPNG_H__
7#include"SDL.h"
8
9/** @namespace png
10 * @brief Utilities for loading and saving PNG images. */
11namespace png {
12
13 /**
14 * @brief Load a PNG file into an SDL_Surface.
15 * @param file Path to the PNG file.
16 * @return Newly allocated SDL_Surface, or nullptr on failure.
17 */
18 SDL_Surface *LoadPNG(const char* file);
19
20 /**
21 * @brief Save an SDL_Texture to a PNG file.
22 * @param texture Source texture.
23 * @param renderer Renderer used to read back the texture pixels.
24 * @param filename Destination file path.
25 * @return @c true on success, @c false on failure.
26 */
27 bool SavePNG(SDL_Texture* texture, SDL_Renderer* renderer, const char* filename);
28
29 /**
30 * @brief Save a raw RGBA pixel buffer to a PNG file.
31 * @param filename Destination file path.
32 * @param buffer Pointer to the raw RGBA pixel data.
33 * @param w Image width in pixels.
34 * @param h Image height in pixels.
35 * @return @c true on success, @c false on failure.
36 */
37 bool SavePNG_RGBA(const char *filename, void *buffer, int w, int h);
38}
39#endif
Utilities for loading and saving PNG images.
Definition loadpng.cpp:21
bool SavePNG(SDL_Texture *texture, SDL_Renderer *renderer, const char *filename)
Save an SDL_Texture to a PNG file.
Definition loadpng.cpp:148
SDL_Surface * LoadPNG(const char *file)
Load a PNG file into an SDL_Surface.
Definition loadpng.cpp:22
bool SavePNG_RGBA(const char *filename, void *buffer, int w, int h)
Save a raw RGBA pixel buffer to a PNG file.
Definition loadpng.cpp:220