MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
mxvk_png.hpp
Go to the documentation of this file.
1/**
2 * @file mxvk_png.hpp
3 * @brief PNG image loading and saving utilities via SDL3.
4 */
5#pragma once
6
7#include <SDL3/SDL.h>
8#include <cstddef>
9
10/** @namespace mxvk
11 * @brief Utilities for loading and saving PNG images. */
12namespace mxvk {
13
14 /**
15 * @brief Load a PNG file into an SDL_Surface.
16 * @param file Path to the PNG file.
17 * @return Newly allocated SDL_Surface, or nullptr on failure.
18 */
19 SDL_Surface *LoadPNG(const char *file);
20
21 /**
22 * @brief Save an SDL_Texture to a PNG file.
23 * @param texture Source texture.
24 * @param renderer Renderer used to read back the texture pixels.
25 * @param filename Destination file path.
26 * @return @c true on success, @c false on failure.
27 */
28 bool SavePNG(SDL_Texture *texture, SDL_Renderer *renderer, const char *filename);
29
30 /**
31 * @brief Save raw data to a file.
32 * @param filename Output file path
33 * @param buffer Pointer to the source data (read-only)
34 * @param w Width of the image in pixels
35 * @param h Height of the image in pixels
36 * @param bpp Bytes per pixel (e.g., 2 for YUYV, 4 for RGBA)
37 * @return @c true on success, @c false on failure.
38 */
39 bool SaveRawBytes(const char *filename, const void *buffer, size_t w, size_t h, size_t bpp);
40 /**
41 * @brief Save a raw RGBA pixel buffer to a PNG file.
42 * @param filename Destination file path.
43 * @param buffer Pointer to the raw RGBA pixel data.
44 * @param w Image width in pixels.
45 * @param h Image height in pixels.
46 * @return @c true on success, @c false on failure.
47 */
48 bool SavePNG_RGBA(const char *filename, void *buffer, int w, int h);
49
50 /**
51 * @brief Save a raw 16-bit RGBA pixel buffer to a PNG file.
52 * @param filename Destination file path.
53 * @param buffer Pointer to the raw 16-bit RGBA pixel data.
54 * @param w Image width in pixels.
55 * @param h Image height in pixels.
56 * @return @c true on success, @c false on failure.
57 */
58 bool SavePNG_RGBA16(const char *filename, const void *buffer, int w, int h);
59} // namespace mxvk
Utilities for loading and saving PNG images.
Definition mxvk.hpp:30
bool SavePNG(SDL_Texture *texture, SDL_Renderer *renderer, const char *filename)
Save an SDL_Texture to a PNG file.
Definition mxvk_png.cpp:200
bool SavePNG_RGBA16(const char *filename, const void *buffer, int w, int h)
Save a raw 16-bit RGBA pixel buffer to a PNG file.
Definition mxvk_png.cpp:311
SDL_Surface * LoadPNG(const char *file)
Load a PNG file into an SDL_Surface.
Definition mxvk_png.cpp:103
bool SavePNG_RGBA(const char *filename, void *buffer, int w, int h)
Save a raw RGBA pixel buffer to a PNG file.
Definition mxvk_png.cpp:300
bool SaveRawBytes(const char *filename, const void *buffer, size_t w, size_t h, size_t bpp)
Save raw data to a file.
Definition mxvk_png.cpp:265