diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-11-17 00:13:07 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-11-17 00:13:07 +0000 |
commit | b0a4b3e2b0feb83c38203011bfd317ecfd48b0f1 (patch) | |
tree | c97bb101cdfe657f7cb5ca5f737c3a8e9b66ee43 /apps/misc.c | |
parent | 4be7e5f560a8046d0a9f8689137cd38eb52b7cbe (diff) | |
download | rockbox-b0a4b3e2b0feb83c38203011bfd317ecfd48b0f1.tar.gz rockbox-b0a4b3e2b0feb83c38203011bfd317ecfd48b0f1.zip |
Fixed the 16bit screendump to work with either endianess and use the 16 bit BMP format.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7920 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/apps/misc.c b/apps/misc.c index 986a52ccb5..858042cf34 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -215,11 +215,17 @@ int read_line(int fd, char* buffer, int buffer_size) | |||
215 | 215 | ||
216 | #ifdef HAVE_LCD_BITMAP | 216 | #ifdef HAVE_LCD_BITMAP |
217 | 217 | ||
218 | #if LCD_DEPTH == 16 | ||
219 | #define BMP_COMPRESSION 3 /* BI_BITFIELDS */ | ||
220 | #define BMP_NUMCOLORS 3 | ||
221 | #else | ||
222 | #define BMP_COMPRESSION 0 /* BI_RGB */ | ||
218 | #if LCD_DEPTH <= 8 | 223 | #if LCD_DEPTH <= 8 |
219 | #define BMP_NUMCOLORS (1 << LCD_DEPTH) | 224 | #define BMP_NUMCOLORS (1 << LCD_DEPTH) |
220 | #else | 225 | #else |
221 | #define BMP_NUMCOLORS 0 | 226 | #define BMP_NUMCOLORS 0 |
222 | #endif | 227 | #endif |
228 | #endif | ||
223 | 229 | ||
224 | #if LCD_DEPTH == 1 | 230 | #if LCD_DEPTH == 1 |
225 | #define BMP_BPP 1 | 231 | #define BMP_BPP 1 |
@@ -230,6 +236,9 @@ int read_line(int fd, char* buffer, int buffer_size) | |||
230 | #elif LCD_DEPTH <= 8 | 236 | #elif LCD_DEPTH <= 8 |
231 | #define BMP_BPP 8 | 237 | #define BMP_BPP 8 |
232 | #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3) | 238 | #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3) |
239 | #elif LCD_DEPTH <= 16 | ||
240 | #define BMP_BPP 16 | ||
241 | #define BMP_LINESIZE ((LCD_WIDTH*2 + 3) & ~3) | ||
233 | #else | 242 | #else |
234 | #define BMP_BPP 24 | 243 | #define BMP_BPP 24 |
235 | #define BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3) | 244 | #define BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3) |
@@ -254,7 +263,7 @@ static const unsigned char bmpheader[] = | |||
254 | LE32_CONST(LCD_HEIGHT), /* Height in pixels */ | 263 | LE32_CONST(LCD_HEIGHT), /* Height in pixels */ |
255 | 0x01, 0x00, /* Number of planes (always 1) */ | 264 | 0x01, 0x00, /* Number of planes (always 1) */ |
256 | LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ | 265 | LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ |
257 | 0x00, 0x00, 0x00, 0x00, /* Compression mode, 0 = none */ | 266 | LE32_CONST(BMP_COMPRESSION),/* Compression mode */ |
258 | LE32_CONST(BMP_DATASIZE), /* Size of bitmap data */ | 267 | LE32_CONST(BMP_DATASIZE), /* Size of bitmap data */ |
259 | 0xc4, 0x0e, 0x00, 0x00, /* Horizontal resolution (pixels/meter) */ | 268 | 0xc4, 0x0e, 0x00, 0x00, /* Horizontal resolution (pixels/meter) */ |
260 | 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */ | 269 | 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */ |
@@ -269,6 +278,10 @@ static const unsigned char bmpheader[] = | |||
269 | 0x99, 0x90, 0x73, 0x00, /* Colour #1 */ | 278 | 0x99, 0x90, 0x73, 0x00, /* Colour #1 */ |
270 | 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */ | 279 | 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */ |
271 | 0x00, 0x00, 0x00, 0x00 /* Colour #3 */ | 280 | 0x00, 0x00, 0x00, 0x00 /* Colour #3 */ |
281 | #elif LCD_DEPTH == 16 | ||
282 | 0x00, 0xf8, 0x00, 0x00, /* red bitfield mask */ | ||
283 | 0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */ | ||
284 | 0x1f, 0x00, 0x00, 0x00 /* blue bitfield mask */ | ||
272 | #endif | 285 | #endif |
273 | }; | 286 | }; |
274 | 287 | ||
@@ -290,10 +303,9 @@ void screen_dump(void) | |||
290 | int src_byte2; | 303 | int src_byte2; |
291 | static unsigned char line_block[4][BMP_LINESIZE]; | 304 | static unsigned char line_block[4][BMP_LINESIZE]; |
292 | #elif LCD_DEPTH == 16 | 305 | #elif LCD_DEPTH == 16 |
293 | static unsigned char line_block[BMP_LINESIZE]; | 306 | static unsigned short line_block[BMP_LINESIZE/2]; |
294 | unsigned char* dst; | 307 | unsigned short* dst; |
295 | unsigned short* src; | 308 | unsigned short* src; |
296 | unsigned short pixel; | ||
297 | #endif | 309 | #endif |
298 | 310 | ||
299 | #ifdef HAVE_RTC | 311 | #ifdef HAVE_RTC |
@@ -358,19 +370,21 @@ void screen_dump(void) | |||
358 | 370 | ||
359 | write(fh, &line_block[0][0], sizeof(line_block)); | 371 | write(fh, &line_block[0][0], sizeof(line_block)); |
360 | } | 372 | } |
361 | #elif LCD_DEPTH==16 | 373 | #elif LCD_DEPTH == 16 |
362 | for (by = LCD_HEIGHT - 1; by >= 0; by--) | 374 | for (by = LCD_HEIGHT - 1; by >= 0; by--) |
363 | { | 375 | { |
364 | memset(line_block, 0, sizeof(line_block)); | 376 | memset(line_block, 0, sizeof(line_block)); |
365 | src=(unsigned short*)&lcd_framebuffer[by][0]; | 377 | src = &lcd_framebuffer[by][0]; |
366 | dst=line_block; | 378 | dst = line_block; |
367 | 379 | ||
368 | for (bx = 0; bx < LCD_WIDTH; bx++) | 380 | for (bx = 0; bx < LCD_WIDTH; bx++) |
369 | { | 381 | { |
370 | pixel=swap16(*(src++)); | 382 | #if (CONFIG_LCD == LCD_IPODCOLOR) || (CONFIG_LCD == LCD_IPODNANO) |
371 | *(dst++)=(pixel&0x1f)<<3; /* Blue */ | 383 | /* iPod LCD data is big endian although the CPU is not */ |
372 | *(dst++)=((pixel&0x07e0)>>5)<<2; /* Green */ | 384 | *dst++ = swap16(*src++); |
373 | *(dst++)=((pixel&0xf800)>>11)<<3; /* Red */ | 385 | #else |
386 | *dst++ = htole16(*src++); | ||
387 | #endif | ||
374 | } | 388 | } |
375 | 389 | ||
376 | write(fh, line_block, sizeof(line_block)); | 390 | write(fh, line_block, sizeof(line_block)); |