1 /*****************************************************************************
2 * This file is part of gfxprim library. *
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. *
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. *
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 *
19 * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
22 * Copyright (C) 2009-2010 Cyril Hrubis <metan@ucw.cz> *
24 *****************************************************************************/
33 #include "GP_RetCode.h"
37 typedef enum GP_PixelType
{
38 /* Unknown pixel type */
51 /* RGB 555 - 15 bits per pixel, 1 bit of padding */
55 /* RGB 565 - 16 bits per pixel */
59 /* RGB - 24bits per pixel */
63 /* RGB + 32bits per pixel, 8 bits of padding */
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 */