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 *****************************************************************************/
29 #include "GP_Context.h"
34 #define GP_PUTPIXEL_1BPP(context, x, y, pixel) do { \
35 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
38 *gp_pix_addr |= (0x80>>(x%8)); \
40 *gp_pix_addr &= ~(0x80>>(x%8)); \
43 #define GP_PUTPIXEL_2BPP(context, x, y, pixel) do { \
44 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
46 *gp_pix_addr = (*gp_pix_addr & ~(0xc0 >> (2*(x%4)))) | \
47 (pixel << (2*(3 - x%4))); \
51 #define GP_PUTPIXEL_4BPP(context, x, y, pixel) do { \
52 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
54 *gp_pix_addr = (*gp_pix_addr & (0xf0 >> (4*(x%2)))) | \
55 (pixel << (4*(1 - x%2))); \
58 #define GP_PUTPIXEL_8BPP(context, x, y, pixel) do { \
59 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
61 *gp_pix_addr = (pixel) & 0xff; \
64 #define GP_PUTPIXEL_16BPP(context, x, y, pixel) do { \
65 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
67 gp_pix_addr[0] = pixel & 0xff; \
68 gp_pix_addr[1] = (pixel>>8) & 0xff; \
71 #define GP_PUTPIXEL_24BPP(context, x, y, pixel) do { \
72 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
74 gp_pix_addr[0] = pixel & 0xff; \
75 gp_pix_addr[1] = (pixel>>8) & 0xff; \
76 gp_pix_addr[2] = (pixel>>16) & 0xff; \
79 #define GP_PUTPIXEL_32BPP(context, x, y, pixel) do { \
80 uint8_t *gp_pix_addr = GP_PIXEL_ADDR(context, x, y); \
82 gp_pix_addr[0] = pixel & 0xff; \
83 gp_pix_addr[1] = (pixel>>8) & 0xff; \
84 gp_pix_addr[2] = (pixel>>16) & 0xff; \
85 gp_pix_addr[3] = (pixel>>24) & 0xff; \
89 * Safe functions, that checks clipping.
91 void GP_PutPixel1bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
92 void GP_PutPixel2bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
93 void GP_PutPixel4bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
94 void GP_PutPixel8bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
95 void GP_PutPixel16bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
96 void GP_PutPixel24bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
97 void GP_PutPixel32bpp(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
102 void GP_PutPixel(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
105 * General rotated putpixel.
107 void GP_TPutPixel(GP_Context
*context
, int x
, int y
, GP_Pixel pixel
);
109 #endif /* GP_PUTPIXEL_H */