4 * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 1999 Bernardo Innocenti <bernie@develer.com>
6 * This file is part of DevLib - See README.devlib for information.
11 * \author Bernardo Innocenti <bernie@develer.com>
13 * \brief Graphics private header.
18 *#* Revision 1.2 2006/02/10 12:28:33 bernie
19 *#* Add font support in bitmaps; Make bitmap formats public.
21 *#* Revision 1.1 2006/01/26 00:32:49 bernie
22 *#* Graphics private header.
30 #if CONFIG_BITMAP_FMT == BITMAP_FMT_PLANAR_H_MSB
32 #define BM_ADDR(bm, x, y) ((bm)->raster + (y) * (bm)->stride + ((x) / 8))
33 #define BM_MASK(bm, x, y) (1 << (7 - (x) % 8))
35 #elif CONFIG_BITMAP_FMT == BITMAP_FMT_PLANAR_V_LSB
37 #define BM_ADDR(bm, x, y) ((bm)->raster + ((y) / 8) * (bm)->stride + (x))
38 #define BM_MASK(bm, x, y) (1 << ((y) % 8))
41 #error Unknown value of CONFIG_BITMAP_FMT
42 #endif /* CONFIG_BITMAP_FMT */
45 * Plot a pixel in bitmap \a bm.
47 * \note bm is evaluated twice.
48 * \see BM_CLEAR BM_DRAWPIXEL
50 #define BM_PLOT(bm, x, y) \
51 ( *BM_ADDR(bm, x, y) |= BM_MASK(bm, x, y) )
54 * Clear a pixel in bitmap \a bm.
56 * \note bm is evaluated twice.
57 * \see BM_PLOT BM_DRAWPIXEL
59 #define BM_CLEAR(bm, x, y) \
60 ( *BM_ADDR(bm, x, y) &= ~BM_MASK(bm, x, y) )
63 * Set a pixel in bitmap \a bm to the specified color.
65 * \note bm is evaluated twice.
66 * \note This macro is somewhat slower than BM_PLOT and BM_CLEAR.
67 * \see BM_PLOT BM_CLEAR
69 #define BM_DRAWPIXEL(bm, x, y, fg_pen) \
71 uint8_t *p = BM_ADDR(bm, x, y); \
72 uint8_t mask = BM_MASK(bm, x, y); \
73 *p = (*p & ~mask) | ((fg_pen) ? mask : 0); \
77 * Get the value of the pixel in bitmap \a bm.
79 * \return The returned value is either 0 or 1.
81 * \note bm is evaluated twice.
84 #define BM_READPIXEL(bm, x, y) \
85 ( *BM_ADDR(bm, x, y) & BM_MASK(bm, x, y) ? 1 : 0 )
88 #endif /* GFX_GFX_P_H */