forked from len0rd/rockbox
Implemented screendump for the player sim.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9977 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
476ba3b6a4
commit
8325e0bf24
3 changed files with 92 additions and 3 deletions
|
@ -18,6 +18,7 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "uisdl.h"
|
#include "uisdl.h"
|
||||||
|
#include "lcd-charcell.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
@ -153,7 +154,6 @@ void button_event(int key, bool pressed)
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
case SDLK_KP0:
|
case SDLK_KP0:
|
||||||
case SDLK_F5:
|
case SDLK_F5:
|
||||||
if(pressed)
|
if(pressed)
|
||||||
|
@ -162,7 +162,6 @@ void button_event(int key, bool pressed)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
case SDLK_KP_PERIOD:
|
case SDLK_KP_PERIOD:
|
||||||
case SDLK_INSERT:
|
case SDLK_INSERT:
|
||||||
|
|
|
@ -17,11 +17,20 @@
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "lcd-playersim.h"
|
#include "lcd-playersim.h"
|
||||||
#include "uisdl.h"
|
#include "uisdl.h"
|
||||||
#include "lcd-sdl.h"
|
#include "lcd-sdl.h"
|
||||||
|
|
||||||
|
/* extern functions, needed for screendump() */
|
||||||
|
extern int sim_creat(const char *name, mode_t mode);
|
||||||
|
extern ssize_t write(int fd, const void *buf, size_t count);
|
||||||
|
extern int close(int fd);
|
||||||
|
|
||||||
SDL_Surface* lcd_surface;
|
SDL_Surface* lcd_surface;
|
||||||
SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0};
|
SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0};
|
||||||
SDL_Color lcd_backlight_color_zero = {UI_LCD_BGCOLORLIGHT, 0};
|
SDL_Color lcd_backlight_color_zero = {UI_LCD_BGCOLORLIGHT, 0};
|
||||||
|
@ -126,7 +135,85 @@ void sim_lcd_init(void)
|
||||||
lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom,
|
lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, LCD_WIDTH * display_zoom,
|
||||||
LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0);
|
LCD_HEIGHT * display_zoom, 8, 0, 0, 0, 0);
|
||||||
|
|
||||||
sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max,
|
sdl_set_gradient(lcd_surface, &lcd_backlight_color_zero, &lcd_color_max,
|
||||||
0, (1<<LCD_DEPTH));
|
0, (1<<LCD_DEPTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BMP_COMPRESSION 0 /* BI_RGB */
|
||||||
|
#define BMP_NUMCOLORS (1 << LCD_DEPTH)
|
||||||
|
#define BMP_BPP 1
|
||||||
|
#define BMP_LINESIZE (((LCD_WIDTH + 31) / 32) * 4)
|
||||||
|
|
||||||
|
#define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS)
|
||||||
|
#define BMP_DATASIZE (BMP_LINESIZE * LCD_HEIGHT)
|
||||||
|
#define BMP_TOTALSIZE (BMP_HEADERSIZE + BMP_DATASIZE)
|
||||||
|
|
||||||
|
#define LE16_CONST(x) (x)&0xff, ((x)>>8)&0xff
|
||||||
|
#define LE32_CONST(x) (x)&0xff, ((x)>>8)&0xff, ((x)>>16)&0xff, ((x)>>24)&0xff
|
||||||
|
|
||||||
|
static const unsigned char bmpheader[] =
|
||||||
|
{
|
||||||
|
0x42, 0x4d, /* 'BM' */
|
||||||
|
LE32_CONST(BMP_TOTALSIZE), /* Total file size */
|
||||||
|
0x00, 0x00, 0x00, 0x00, /* Reserved */
|
||||||
|
LE32_CONST(BMP_HEADERSIZE), /* Offset to start of pixel data */
|
||||||
|
|
||||||
|
0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */
|
||||||
|
LE32_CONST(LCD_WIDTH), /* Width in pixels */
|
||||||
|
LE32_CONST(LCD_HEIGHT), /* Height in pixels */
|
||||||
|
0x01, 0x00, /* Number of planes (always 1) */
|
||||||
|
LE16_CONST(BMP_BPP), /* Bits per pixel 1/4/8/16/24 */
|
||||||
|
LE32_CONST(BMP_COMPRESSION),/* Compression mode */
|
||||||
|
LE32_CONST(BMP_DATASIZE), /* Size of bitmap data */
|
||||||
|
0xc4, 0x0e, 0x00, 0x00, /* Horizontal resolution (pixels/meter) */
|
||||||
|
0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */
|
||||||
|
LE32_CONST(BMP_NUMCOLORS), /* Number of used colours */
|
||||||
|
LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */
|
||||||
|
|
||||||
|
0x90, 0xee, 0x90, 0x00, /* Colour #0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00 /* Colour #1 */
|
||||||
|
};
|
||||||
|
|
||||||
|
void screen_dump(void)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
char filename[MAX_PATH];
|
||||||
|
int x, y;
|
||||||
|
static unsigned char line[BMP_LINESIZE];
|
||||||
|
|
||||||
|
create_numbered_filename(filename, "", "dump_", ".bmp", 4);
|
||||||
|
DEBUGF("screen_dump\n");
|
||||||
|
|
||||||
|
fd = sim_creat(filename, 1 /*O_WRONLY*/);
|
||||||
|
if (fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
write(fd, bmpheader, sizeof(bmpheader));
|
||||||
|
SDL_LockSurface(lcd_surface);
|
||||||
|
|
||||||
|
/* BMP image goes bottom up */
|
||||||
|
for (y = LCD_HEIGHT - 1; y >= 0; y--)
|
||||||
|
{
|
||||||
|
Uint8 *src = (Uint8 *)lcd_surface->pixels
|
||||||
|
+ y * LCD_WIDTH * display_zoom * display_zoom;
|
||||||
|
unsigned char *dst = line;
|
||||||
|
unsigned dst_mask = 0x80;
|
||||||
|
|
||||||
|
memset(line, 0, sizeof(line));
|
||||||
|
for (x = LCD_WIDTH; x > 0; x--)
|
||||||
|
{
|
||||||
|
if (*src)
|
||||||
|
*dst |= dst_mask;
|
||||||
|
src += display_zoom;
|
||||||
|
dst_mask >>= 1;
|
||||||
|
if (dst_mask == 0)
|
||||||
|
{
|
||||||
|
dst++;
|
||||||
|
dst_mask = 0x80;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write(fd, line, sizeof(line));
|
||||||
|
}
|
||||||
|
SDL_UnlockSurface(lcd_surface);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
|
@ -23,7 +23,10 @@
|
||||||
#include "lcd.h"
|
#include "lcd.h"
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_CHARCELLS
|
||||||
void sim_lcd_init(void);
|
void sim_lcd_init(void);
|
||||||
|
void screen_dump(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* #ifndef __LCDCHARCELL_H__ */
|
#endif /* #ifndef __LCDCHARCELL_H__ */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue