diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-07-25 20:50:34 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-07-25 20:50:34 +0000 |
commit | c20a00ef3e35b15acf422a2e7f6716abde840c24 (patch) | |
tree | 903cf122a1203360022dad4a06cc24b7ea805463 /apps/plugins/lib/gray_screendump.c | |
parent | 12a4ed383f21b65a5a244f47fe1bc9f13d4f63bb (diff) | |
download | rockbox-c20a00ef3e35b15acf422a2e7f6716abde840c24.tar.gz rockbox-c20a00ef3e35b15acf422a2e7f6716abde840c24.zip |
Complete rework of the grayscale library: (1) Implemented the new rockbox graphics api. (2) Added buffered mode, and implemented most drawing functions for buffered mode only. Buffered mode will ease implementation of animated graphics. Some functions are additionally provided as unbuffered versions (drawing grayscale bitmaps, scrolling) since unbuffered mode is better suited for non-animated graphics (JPEG viewer, mandelbrot) and saves some RAM, which is important on Archos. (3) Put all functions in a couple of source files, no more one-function-per-files. This became possible since sectioned compilation for the plugin library and appropriate linking for the pluginswas introduced, otherwise the binaries would be bloated by unused functions.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7241 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib/gray_screendump.c')
-rw-r--r-- | apps/plugins/lib/gray_screendump.c | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/apps/plugins/lib/gray_screendump.c b/apps/plugins/lib/gray_screendump.c deleted file mode 100644 index fdc88b8547..0000000000 --- a/apps/plugins/lib/gray_screendump.c +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
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 const 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 | |||