libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
jpeg.hpp
Go to the documentation of this file.
1/**
2 * @file jpeg.hpp
3 * @brief JPEG image loading and saving utilities (requires WITH_JPEG build flag).
4 */
5#ifndef __JPEG_H__
6#define __JPEG_H__
7#ifdef __EMSCRIPTEN__
8#include"config.hpp"
9#else
10#include"config.h"
11#endif
12#ifdef WITH_JPEG
13#include "SDL.h"
14
15/** @namespace jpeg
16 * @brief Utilities for loading and saving JPEG images. */
17namespace jpeg {
18
19/**
20 * @brief Load a JPEG file into an SDL_Surface.
21 * @param src Path to the JPEG file.
22 * @return Newly allocated SDL_Surface, or nullptr on failure.
23 */
24SDL_Surface *LoadJPEG(const char *src);
25
26/**
27 * @brief Save an SDL_Texture to a JPEG file.
28 * @param renderer SDL renderer used to read back pixel data.
29 * @param texture Source texture.
30 * @param filename Destination file path.
31 * @param quality JPEG quality (0–100, default 90).
32 * @return @c true on success, @c false on failure.
33 */
34bool SaveJPEG(SDL_Renderer *renderer, SDL_Texture *texture, const char *filename, int quality = 90);
35}
36#endif
37#endif
Compile-time feature flags and version macros for libmx.
Utilities for loading and saving JPEG images.
Definition jpeg.cpp:17
SDL_Surface * LoadJPEG(const char *filename)
Load a JPEG file into an SDL_Surface.
Definition jpeg.cpp:32
bool SaveJPEG(SDL_Renderer *renderer, SDL_Texture *texture, const char *filename, int quality)
Save an SDL_Texture to a JPEG file.
Definition jpeg.cpp:79