diff options
author | Jens Arnold <amiconn@rockbox.org> | 2004-07-06 23:11:02 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2004-07-06 23:11:02 +0000 |
commit | d073326b6b16698efc8e897269826449cfc40699 (patch) | |
tree | f3fb4d6f8dadcd0afcb61b776e8439a1425d62c5 /apps/plugins/lib | |
parent | ccba5553f77eddfc2d28dcbdb0184adc0c08f995 (diff) | |
download | rockbox-d073326b6b16698efc8e897269826449cfc40699.tar.gz rockbox-d073326b6b16698efc8e897269826449cfc40699.zip |
Added screen dump function to the grayscale lib
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4843 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/gray.h | 11 | ||||
-rw-r--r-- | apps/plugins/lib/gray_screendump.c | 141 |
2 files changed, 152 insertions, 0 deletions
diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h index 918d7ecb4a..c8a9afc390 100644 --- a/apps/plugins/lib/gray.h +++ b/apps/plugins/lib/gray.h | |||
@@ -181,6 +181,17 @@ void gray_set_background(int brightness); | |||
181 | */ | 181 | */ |
182 | void gray_set_drawinfo(int drawmode, int fg_brightness, int bg_brightness); | 182 | void gray_set_drawinfo(int drawmode, int fg_brightness, int bg_brightness); |
183 | 183 | ||
184 | /*--------------------------------------------------------------------------- | ||
185 | Save the current display content (b&w and grayscale overlay) to an 8-bit | ||
186 | BMP file in the root directory | ||
187 | ---------------------------------------------------------------------------- | ||
188 | * | ||
189 | * This one is rather slow if used with larger bit depths, but it's intended | ||
190 | * primary use is for documenting the grayscale plugins. A much faster version | ||
191 | * would be possible, but would take more than twice the RAM | ||
192 | */ | ||
193 | void gray_screendump(void); | ||
194 | |||
184 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 195 | /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
185 | Functions affecting the whole display | 196 | Functions affecting the whole display |
186 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 197 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
diff --git a/apps/plugins/lib/gray_screendump.c b/apps/plugins/lib/gray_screendump.c new file mode 100644 index 0000000000..8968007039 --- /dev/null +++ b/apps/plugins/lib/gray_screendump.c | |||
@@ -0,0 +1,141 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Grayscale framework | ||
11 | * gray_screendump() 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 | static unsigned char bmpheader[] = | ||
33 | { | ||
34 | 0x42, 0x4d, 0xba, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0x00, | ||
35 | 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x40, 0x00, | ||
36 | 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, | ||
37 | 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0x21, 0x00, | ||
38 | 0x00, 0x00, 0x21, 0x00, 0x00, 0x00 | ||
39 | }; | ||
40 | |||
41 | static unsigned char linebuf[LCD_WIDTH]; | ||
42 | |||
43 | /*--------------------------------------------------------------------------- | ||
44 | Save the current display content (b&w and grayscale overlay) to an 8-bit | ||
45 | BMP file in the root directory | ||
46 | ---------------------------------------------------------------------------- | ||
47 | * | ||
48 | * This one is rather slow if used with larger bit depths, but it's intended | ||
49 | * primary use is for documenting the grayscale plugins. A much faster version | ||
50 | * would be possible, but would take more than twice the RAM | ||
51 | */ | ||
52 | void gray_screendump(void) | ||
53 | { | ||
54 | int fh, i, bright; | ||
55 | int x, y, by, mask; | ||
56 | int gx, gby; | ||
57 | |||
58 | char filename[MAX_PATH]; | ||
59 | struct tm *tm = _gray_rb->get_time(); | ||
60 | |||
61 | unsigned char *lcdptr, *grayptr, *grayptr2; | ||
62 | |||
63 | _gray_rb->snprintf(filename, MAX_PATH, | ||
64 | "/graydump %04d-%02d-%02d %02d-%02d-%02d.bmp", | ||
65 | tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, | ||
66 | tm->tm_hour, tm->tm_min, tm->tm_sec); | ||
67 | fh = _gray_rb->creat(filename, O_WRONLY); | ||
68 | |||
69 | if (fh < 0) | ||
70 | return; | ||
71 | |||
72 | _gray_rb->write(fh, bmpheader, sizeof(bmpheader)); /* write header */ | ||
73 | |||
74 | /* build clut, always 33 entries */ | ||
75 | |||
76 | linebuf[3] = 0; | ||
77 | |||
78 | for (i = 0; i < 33; i++) | ||
79 | { | ||
80 | bright = MIN(i, _graybuf->depth); | ||
81 | linebuf[0] = linebuf[2] = MULU16(0x90, bright) / _graybuf->depth; | ||
82 | linebuf[1] = MULU16(0xee, bright) / _graybuf->depth; | ||
83 | _gray_rb->write(fh, linebuf, 4); | ||
84 | } | ||
85 | |||
86 | /* 8-bit BMP image goes bottom -> top */ | ||
87 | |||
88 | for (y = LCD_HEIGHT - 1; y >= 0; y--) | ||
89 | { | ||
90 | _gray_rb->memset(linebuf, 32, sizeof(linebuf)); /* max. brightness */ | ||
91 | |||
92 | mask = 1 << (y & 7); | ||
93 | by = y / 8; | ||
94 | lcdptr = _gray_rb->lcd_framebuffer + MULU16(LCD_WIDTH, by); | ||
95 | gby = by - _graybuf->by; | ||
96 | |||
97 | if ((_graybuf->flags & _GRAY_RUNNING) | ||
98 | && (unsigned) gby < (unsigned) _graybuf->bheight) | ||
99 | { | ||
100 | /* line contains grayscale (and maybe b&w) graphics */ | ||
101 | grayptr = _graybuf->data + MULU16(_graybuf->width, gby); | ||
102 | |||
103 | for (x = 0; x < LCD_WIDTH; x++) | ||
104 | { | ||
105 | if (*lcdptr++ & mask) | ||
106 | linebuf[x] = 0; | ||
107 | |||
108 | gx = x - _graybuf->x; | ||
109 | |||
110 | if ((unsigned) gx < (unsigned) _graybuf->width) | ||
111 | { | ||
112 | bright = 0; | ||
113 | grayptr2 = grayptr + gx; | ||
114 | |||
115 | for (i = 0; i < _graybuf->depth; i++) | ||
116 | { | ||
117 | if (!(*grayptr2 & mask)) | ||
118 | bright++; | ||
119 | grayptr2 += _graybuf->plane_size; | ||
120 | } | ||
121 | linebuf[x] = bright; | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | /* line contains only b&w graphics */ | ||
128 | for (x = 0; x < LCD_WIDTH; x++) | ||
129 | if (*lcdptr++ & mask) | ||
130 | linebuf[x] = 0; | ||
131 | } | ||
132 | |||
133 | _gray_rb->write(fh, linebuf, sizeof(linebuf)); | ||
134 | } | ||
135 | |||
136 | _gray_rb->close(fh); | ||
137 | } | ||
138 | |||
139 | #endif // #ifdef HAVE_LCD_BITMAP | ||
140 | #endif // #ifndef SIMULATOR | ||
141 | |||