summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/gray_drawbitmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/gray_drawbitmap.c')
-rw-r--r--apps/plugins/lib/gray_drawbitmap.c116
1 files changed, 0 insertions, 116 deletions
diff --git a/apps/plugins/lib/gray_drawbitmap.c b/apps/plugins/lib/gray_drawbitmap.c
deleted file mode 100644
index 376f76d45e..0000000000
--- a/apps/plugins/lib/gray_drawbitmap.c
+++ /dev/null
@@ -1,116 +0,0 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Grayscale framework
11* gray_drawbitmap() function
12*
13* This is a generic framework to use grayscale display within Rockbox
14* plugins. It obviously does not work for the player.
15*
16* Copyright (C) 2004 Jens Arnold
17*
18* All files in this archive are subject to the GNU General Public License.
19* See the file COPYING in the source tree root for full license agreement.
20*
21* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22* KIND, either express or implied.
23*
24****************************************************************************/
25
26#ifndef SIMULATOR /* not for simulator by now */
27#include "plugin.h"
28
29#ifdef HAVE_LCD_BITMAP /* and also not for the Player */
30#include "gray.h"
31
32/*---------------------------------------------------------------------------
33 Display a bitmap with the current drawinfo
34 ----------------------------------------------------------------------------
35 The drawmode is used as described for gray_set_drawmode()
36
37 This (now) uses the same bitmap format as the core b&w graphics routines,
38 so you can use bmp2rb to generate bitmaps for use with this function as
39 well.
40
41 A bitmap contains one bit for every pixel that defines if that pixel is
42 foreground (1) or background (0). Bits within a byte are arranged
43 vertically, LSB at top.
44 The bytes are stored in row-major order, with byte 0 being top left,
45 byte 1 2nd from left etc. The first row of bytes defines pixel rows
46 0..7, the second row defines pixel row 8..15 etc.
47
48 The <stride> parameter is useful if you want to show only a part of a
49 bitmap. It should always be set to the "row length" of the bitmap.
50 */
51void gray_drawbitmap(const unsigned char *src, int x, int y, int nx, int ny,
52 int stride)
53{
54 int shift;
55 unsigned bits, mask_top, mask_bottom;
56 const unsigned char *src_col;
57 unsigned char *dst, *dst_col;
58 void (*blockfunc)(unsigned char *address, unsigned mask, unsigned bits);
59
60 if ((unsigned) x >= (unsigned) _graybuf->width
61 || (unsigned) y >= (unsigned) _graybuf->height)
62 return;
63
64 if ((unsigned) (y + ny) >= (unsigned) _graybuf->height) /* clip bottom */
65 ny = _graybuf->height - y;
66
67 if ((unsigned) (x + nx) >= (unsigned) _graybuf->width) /* clip right */
68 nx = _graybuf->width - x;
69
70 dst = _graybuf->data + x + MULU16(_graybuf->width, y >> 3);
71 shift = y & 7;
72 ny += shift;
73
74 mask_top = 0xFFu << (y & 7);
75 mask_bottom = ~(0xFEu << ((ny - 1) & 7));
76 if (ny <= 8)
77 mask_bottom &= mask_top;
78
79 blockfunc = _gray_blockfuncs[_graybuf->drawmode];
80
81 for(x = 0; x < nx; x++)
82 {
83 src_col = src++;
84 dst_col = dst++;
85 bits = 0;
86 y = 0;
87
88 if (ny > 8)
89 {
90 bits = *src_col << shift;
91 src_col += stride;
92
93 blockfunc(dst_col, mask_top, bits);
94 dst_col += _graybuf->width;
95 bits >>= 8;
96
97 for (y = 8; y < ny - 8; y += 8)
98 {
99 bits |= *src_col << shift;
100 src_col += stride;
101
102 blockfunc(dst_col, 0xFFu, bits);
103 dst_col += _graybuf->width;
104 bits >>= 8;
105 }
106 }
107 if (y + shift < ny)
108 bits |= *src_col << shift;
109
110 blockfunc(dst_col, mask_bottom, bits);
111 }
112}
113
114#endif // #ifdef HAVE_LCD_BITMAP
115#endif // #ifndef SIMULATOR
116