libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
jpeg Namespace Reference

Utilities for loading and saving JPEG images. More...

Classes

struct  my_error_mgr

Typedefs

typedef struct my_error_mgr * my_error_ptr

Functions

void my_error_exit (j_common_ptr cinfo)
SDL_Surface * LoadJPEG (const char *src)
 Load a JPEG file into an SDL_Surface.
bool SaveJPEG (SDL_Renderer *renderer, SDL_Texture *texture, const char *filename, int quality=90)
 Save an SDL_Texture to a JPEG file.

Detailed Description

Utilities for loading and saving JPEG images.

Typedef Documentation

◆ my_error_ptr

Definition at line 24 of file jpeg.cpp.

Function Documentation

◆ LoadJPEG()

SDL_Surface * jpeg::LoadJPEG ( const char * src)

Load a JPEG file into an SDL_Surface.

Parameters
srcPath to the JPEG file.
Returns
Newly allocated SDL_Surface, or nullptr on failure.

Definition at line 32 of file jpeg.cpp.

References my_error_exit(), jpeg::my_error_mgr::pub, and jpeg::my_error_mgr::setjmp_buffer.

Referenced by mx::Texture::loadTexture().

◆ my_error_exit()

void jpeg::my_error_exit ( j_common_ptr cinfo)

Definition at line 26 of file jpeg.cpp.

References jpeg::my_error_mgr::setjmp_buffer.

Referenced by LoadJPEG().

◆ SaveJPEG()

bool jpeg::SaveJPEG ( SDL_Renderer * renderer,
SDL_Texture * texture,
const char * filename,
int quality = 90 )

Save an SDL_Texture to a JPEG file.

Parameters
rendererSDL renderer used to read back pixel data.
textureSource texture.
filenameDestination file path.
qualityJPEG quality (0–100, default 90).
Returns
true on success, false on failure.

Definition at line 79 of file jpeg.cpp.

Referenced by mx::Texture::saveTexture().