summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-04-14 15:58:51 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-04-14 15:58:51 +0000
commita97de95ed9fc2e43c2daff520f9767905d3232a7 (patch)
tree856b8bab676ca379b36e8bb3616aae24545d1de8
parent1b8c6626b3d4586e2c473b1a6e76202b51eb3661 (diff)
downloadrockbox-a97de95ed9fc2e43c2daff520f9767905d3232a7.tar.gz
rockbox-a97de95ed9fc2e43c2daff520f9767905d3232a7.zip
Added screen_dump() for future use
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3554 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/misc.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 0226cc2b2f..a49739f92d 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -16,7 +16,10 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19#include "string.h"
20#include "config.h"
21#include "file.h"
22#include "lcd.h"
20#include "sprintf.h" 23#include "sprintf.h"
21#define ONE_KILOBYTE 1024 24#define ONE_KILOBYTE 1024
22#define ONE_MEGABYTE (1024*1024) 25#define ONE_MEGABYTE (1024*1024)
@@ -59,3 +62,69 @@ int main(int argc, char **argv)
59} 62}
60 63
61#endif 64#endif
65
66#ifdef SCREENDUMP
67extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8];
68static unsigned char bmpheader[] =
69{
70 0x42, 0x4d, 0x3e, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
71 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x40, 0x00,
72 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
73 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0x00, 0x00,
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xd0, 0x80, 0x00, 0x00, 0x00,
75 0x00, 0x00
76};
77
78static unsigned char buf[112*8];
79static unsigned char buf2[112*8];
80static char dummy[2] = {0, 0};
81static int fileindex = 0;
82
83void screen_dump(void)
84{
85 int f;
86 int i, shift;
87 int x, y;
88 char filename[MAX_PATH];
89
90 i = 0;
91 for(y = 0;y < LCD_HEIGHT/8;y++)
92 {
93 for(x = 0;x < LCD_WIDTH;x++)
94 {
95 buf[i++] = lcd_framebuffer[x][y];
96 }
97 }
98
99 memset(buf2, 0, sizeof(buf2));
100
101 for(y = 0;y < 64;y++)
102 {
103 shift = y & 7;
104
105 for(x = 0;x < 112/8;x++)
106 {
107 for(i = 0;i < 8;i++)
108 {
109 buf2[y*112/8+x] |= ((buf[y/8*112+x*8+i] >> shift)
110 & 0x01) << (7-i);
111 }
112 }
113 }
114
115 snprintf(filename, MAX_PATH, "/dump%03d.bmp", fileindex++);
116 f = creat(filename, O_WRONLY);
117 if(f >= 0)
118 {
119 write(f, bmpheader, sizeof(bmpheader));
120
121 for(i = 63;i >= 0;i--)
122 {
123 write(f, &buf2[i*14], 14);
124 write(f, dummy, 2);
125 }
126
127 close(f);
128 }
129}
130#endif