Added .gitignore
[gfxprim.git] / core / GP_Pixel.h
bloba73be83d949d23078ba59d83c61c42df49eda366
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
21 * *
22 * Copyright (C) 2009-2010 Cyril Hrubis <metan@ucw.cz> *
23 * *
24 *****************************************************************************/
26 #ifndef GP_PIXEL_H
27 #define GP_PIXEL_H
29 #include <stdbool.h>
30 #include <stdint.h>
32 #include "GP_Color.h"
33 #include "GP_RetCode.h"
35 struct GP_Context;
37 typedef enum GP_PixelType {
38 /* Unknown pixel type */
39 GP_PIXEL_UNKNOWN = 0,
41 /* Palete */
42 GP_PIXEL_PAL4,
43 GP_PIXEL_PAL8,
45 /* Grayscale */
46 GP_PIXEL_G1,
47 GP_PIXEL_G2,
48 GP_PIXEL_G4,
49 GP_PIXEL_G8,
51 /* RGB 555 - 15 bits per pixel, 1 bit of padding */
52 GP_PIXEL_RGB555,
53 GP_PIXEL_BGR555,
55 /* RGB 565 - 16 bits per pixel */
56 GP_PIXEL_RGB565,
57 GP_PIXEL_BGR565,
59 /* RGB - 24bits per pixel */
60 GP_PIXEL_RGB888,
61 GP_PIXEL_BGR888,
63 /* RGB + 32bits per pixel, 8 bits of padding */
64 GP_PIXEL_XRGB8888,
65 GP_PIXEL_RGBX8888,
66 GP_PIXEL_XBGR8888,
67 GP_PIXEL_BGRX8888,
69 /* RGB + alpha */
70 GP_PIXEL_ARGB8888,
71 GP_PIXEL_RGBA8888,
72 GP_PIXEL_ABGR8888,
73 GP_PIXEL_BGRA8888,
75 GP_PIXEL_MAX,
76 } GP_PixelType;
78 typedef uint32_t GP_Pixel;
81 * Convert pixel type to name.
83 const char *GP_PixelTypeName(GP_PixelType type);
86 * Returns number of bits per pixel.
88 uint32_t GP_PixelSize(GP_PixelType type);
91 * Returns GP_PixelType to GP_ColorType mapping.
93 GP_ColorType GP_PixelTypeToColorType(GP_PixelType type);
96 * Converts a color to the specified pixel type.
98 GP_RetCode GP_ColorToPixelType(GP_PixelType pixel_type, GP_Color color, GP_Pixel *pixel);
101 * Converts a color to a pixel value suitable for the specified context.
103 GP_RetCode GP_ColorToPixel(struct GP_Context *context, GP_Color color, GP_Pixel *pixel);
108 GP_RetCode GP_ColorNameToPixel(struct GP_Context *context, GP_ColorName name, GP_Pixel *pixel);
111 * Converts a color name to the specified pixel type.
113 GP_RetCode GP_ColorNameToPixelType(GP_PixelType pixel_type, GP_ColorName name, GP_Pixel *pixel);
116 * Converts a color specified by its R, G, B components to a pixel value
117 * compatible with the specified context.
119 GP_RetCode GP_RGBToPixel(struct GP_Context *context, uint8_t r, uint8_t g, uint8_t b, GP_Pixel *pixel);
121 #endif /* GP_PIXEL_H */