Added GP_CHECK_EqualColors macro
[gfxprim.git] / doc / basic_types.txt
blob9bcba9ee9c841e1c344356aa480530b2def24cf9
1 Basic types
2 -----------
3 Return Code
4 ~~~~~~~~~~~
6 Basically each gfxprim function returns one of following return codes:
8 [source,c]
9 --------------------------------------------------------------------------------
10 typedef enum GP_RetCode {
11         GP_ESUCCESS,
12         GP_EINVAL,
13         GP_ENOIMPL,
14         GP_EUNPRECISE,
15         GP_ENULLPTR,            /* some argument was unexpectedly NULL */
16         GP_EBACKENDLOST,
17         GP_EBADCONTEXT,         /* context contains invalid data */
18         GP_EBADFILE,            /* error in file, or bad file format */
19         GP_ENOENT,              /* no such file or another object */
20         GP_ENOMEM,              /* not enough memory */
21         GP_EMAX,
22 } GP_RetCode;
23 --------------------------------------------------------------------------------
25 Return codes could be translated into an error messages.
27 [source,c]
28 --------------------------------------------------------------------------------
29 const char *GP_RetCodeName(GP_RetCode code);
30 --------------------------------------------------------------------------------
32 Color and pixel types
33 ~~~~~~~~~~~~~~~~~~~~~
35 The color, in gfxprim is abstract value that represents color in some format,
36 while pixel is color in format of the target bitmap.
38 Color and pixel types could be converted between each other but certain
39 conversions lose information.
41 Color types are defined in 'core/GP_Color.h' and pixels in 'core/GP_Pixel.h'.
42 The color is union of structures so that is easy to manipulate with each color
43 types, the pixel is basically sequence of bytes stored in long enough integer
44 number.
46 Before drawing a shape into a bitmap, color must be converted into pixel as
47 all drawing functions takes pixel rather than color.
49 The color types:
51 [source,c]
52 --------------------------------------------------------------------------------
53 typedef enum GP_ColorType {
54         GP_NOCOLOR = 0,
55         GP_COLNAME,
56         GP_PALETTE,
57         GP_PAL4,
58         GP_PAL8,
59         GP_G1,
60         GP_G2,
61         GP_G4,
62         GP_G8,
63         GP_RGB555,
64         GP_RGB565,
65         GP_RGB666,
66         GP_RGB888,
67         GP_RGBA8888,
68         GP_COLMAX,
69 } GP_ColorType;
70 --------------------------------------------------------------------------------
72 Predefined names are provided for the most basic colors:
74 [source,c]
75 --------------------------------------------------------------------------------
76 typedef enum GP_ColorName {
77         GP_COL_BLACK,
78         GP_COL_RED,
79         GP_COL_GREEN,
80         GP_COL_BLUE,
81         GP_COL_YELLOW,
82         GP_COL_BROWN,
83         GP_COL_ORANGE,
84         GP_COL_GRAY_DARK,
85         GP_COL_GRAY_LIGHT,
86         GP_COL_PURPLE,
87         GP_COL_WHITE,
88         GP_COL_MAX,
89 } GP_ColorName;
90 --------------------------------------------------------------------------------
92 To convert color to context pixel type use:
94 [source,c]
95 --------------------------------------------------------------------------------
96 GP_RetCode GP_ColorToPixel(struct GP_Context *context, GP_Color color,
97                            GP_Pixel *pixel);
99 GP_RetCode GP_ColorNameToPixel(struct GP_Context *context, GP_ColorName name,
100                                GP_Pixel *pixel);
101 --------------------------------------------------------------------------------