GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Toggle main menu visibility
Main Page
Topics
Data Structures
Data Structures
Data Structure Index
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Files
File List
Globals
All
g
j
Functions
g
Variables
Typedefs
g
Enumerations
g
j
Enumerator
g
Macros
g
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
include
backends
gp_sdl_pixmap.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/*
3
* Copyright (C) 2009-2021 Cyril Hrubis <metan@ucw.cz>
4
*/
5
10
#ifndef BACKENDS_GP_SDL_PIXMAP_H
11
#define BACKENDS_GP_SDL_PIXMAP_H
12
13
#include <
core/gp_pixel.h
>
14
#include <
core/gp_pixmap.h
>
15
43
static
inline
int
gp_pixmap_from_sdl_surface
(
gp_pixmap
*pixmap,
44
const
SDL_Surface *surf)
45
{
46
/* sanity checks on the SDL surface */
47
if
(surf->format->BytesPerPixel == 0) {
48
GP_WARN
(
"Surface->BytesPerPixel == 0"
);
49
return
1;
50
}
51
52
if
(surf->format->BytesPerPixel > 4) {
53
GP_WARN
(
"Surface->BytesPerPixel > 4"
);
54
return
1;
55
}
56
57
enum
gp_pixel_type
pixeltype =
gp_pixel_rgb_match
(surf->format->Rmask,
58
surf->format->Gmask,
59
surf->format->Bmask,
60
surf->format->Ashift,
61
surf->format->BitsPerPixel);
62
63
if
(pixeltype == GP_PIXEL_UNKNOWN)
64
return
1;
65
66
/* basic structure and size */
67
pixmap->
pixels
= surf->pixels;
68
pixmap->
pixel_type
= pixeltype;
69
pixmap->
bytes_per_row
= surf->pitch;
70
pixmap->
w
= surf->w;
71
pixmap->
h
= surf->h;
72
pixmap->
gamma
= NULL;
73
74
return
0;
75
}
43
static
inline
int
gp_pixmap_from_sdl_surface
(
gp_pixmap
*pixmap, {
…
}
76
77
#endif
/* BACKENDS_GP_SDL_PIXMAP_H */
GP_WARN
#define GP_WARN(...)
A debug WARN printf-like macro.
Definition
gp_debug.h:104
gp_pixel_type
gp_pixel_type
List of all pixel types.
Definition
gp_pixel.gen.h:62
gp_pixel.h
A pixel description.
gp_pixel_rgb_match
gp_pixel_type gp_pixel_rgb_match(gp_pixel rmask, gp_pixel gmask, gp_pixel bmask, gp_pixel amask, uint8_t bits_per_pixel)
Matches a RGB pixel type againts known pixel types.
gp_pixmap.h
A pixel buffer.
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.
Definition
gp_sdl_pixmap.h:43
gp_pixmap
A pixmap buffer.
Definition
gp_pixmap.h:33
gp_pixmap::h
uint32_t h
Pixmap height in pixels.
Definition
gp_pixmap.h:46
gp_pixmap::pixels
uint8_t * pixels
A pointer to image pixels.
Definition
gp_pixmap.h:35
gp_pixmap::pixel_type
enum gp_pixel_type pixel_type
A pixel format.
Definition
gp_pixmap.h:63
gp_pixmap::bytes_per_row
uint32_t bytes_per_row
Number of bytes per row.
Definition
gp_pixmap.h:42
gp_pixmap::gamma
gp_gamma * gamma
A pointer to a gamma correction table.
Definition
gp_pixmap.h:70
gp_pixmap::w
uint32_t w
Pixmap width in pixels.
Definition
gp_pixmap.h:44
Generated by
1.9.8