2D bitmap graphics library with emphasis on speed and correctness
No Matches
gp_sdl_pixmap.h File Reference

A SDL surface to GFXprim pixmap conversion. More...

#include <core/gp_pixel.h>
#include <core/gp_pixmap.h>

Go to the source code of this file.


static int gp_pixmap_from_sdl_surface (gp_pixmap *pixmap, const SDL_Surface *surf)
 A SDL surface to GFXprim pixmap conversion.

Detailed Description

A SDL surface to GFXprim pixmap conversion.

Definition in file gp_sdl_pixmap.h.

Function Documentation

◆ gp_pixmap_from_sdl_surface()

static int gp_pixmap_from_sdl_surface ( gp_pixmap pixmap,
const SDL_Surface *  surf 

A SDL surface to GFXprim pixmap conversion.

This function lets you use GFXprim together with SDL. All you need to do is to initialize pixmap from surface. The usage is as follows:

if (gp_pixmap_from_sdl_surface(&c, surface)) {
error("Failed to match PIXEL_TYPE for given surface");
// The pixmap has gamma set to 1.0 which is unlikely correct
// Use gp_pixmap_correction_set() to assign correct correction.
static int gp_pixmap_from_sdl_surface(gp_pixmap *pixmap, const SDL_Surface *surf)
A SDL surface to GFXprim pixmap conversion.
A pixmap buffer.
Definition gp_pixmap.h:33

Now you have initialized pixmap that shares the pixel buffer with the SDL surface.

TODO: Make use of the SDL_GetGammaRamp()?

pixmapA pointer to a pixmap to be initialized.
surfA SDL surface to be mapped into pixmap.
A zero on success, non-zero if pixel type couldn't be mapped.

Definition at line 43 of file gp_sdl_pixmap.h.

References gp_pixmap::bytes_per_row, gp_pixmap::gamma, gp_pixel_rgb_match(), GP_WARN, gp_pixmap::h, gp_pixmap::pixel_type, gp_pixmap::pixels, and gp_pixmap::w.