- several fixes related to the graphics snapshot feature

- fixed size entries in bitmap file header for 8 bpp
  - bx_param_filename_c now uses the file extension from the initial value as
    the default (if present)
  - SIM->ask_filename() now uses the correct parameter type
  - win32paramdlg AskFilename(): added filter for BMP files
This commit is contained in:
Volker Ruppert 2011-08-09 09:56:00 +00:00
parent c6c94a79da
commit 9669929cbb
4 changed files with 16 additions and 4 deletions

View File

@ -472,6 +472,9 @@ void bx_gui_c::snapshot_handler(void)
iBits = (iDepth == 8) ? 8 : 24;
rlen = (iWidth * (iBits >> 3) + 3) & ~3;
len = rlen * iHeight + 54;
if ((iDepth == 8) && (palette_ptr != NULL)) {
len += (256 * 4);
}
memset(bmp_header, 0, 54);
bmp_header[0] = 0x42;
bmp_header[1] = 0x4d;
@ -480,6 +483,9 @@ void bx_gui_c::snapshot_handler(void)
bmp_header[4] = (len >> 16) & 0xff;
bmp_header[5] = (len >> 24) & 0xff;
bmp_header[10] = 54;
if ((iDepth == 8) && (palette_ptr != NULL)) {
bmp_header[11] = 4;
}
bmp_header[14] = 40;
bmp_header[18] = iWidth & 0xff;
bmp_header[19] = (iWidth >> 8) & 0xff;

View File

@ -697,7 +697,12 @@ bx_param_filename_c::bx_param_filename_c(bx_param_c *parent,
: bx_param_string_c(parent, name, label, description, initial_val, maxsize)
{
set_options(IS_FILENAME);
ext = NULL;
int len = strlen(initial_val);
if ((len > 4) && (initial_val[len - 4] == '.')) {
ext = &initial_val[len - 3];
} else {
ext = NULL;
}
}
bx_param_string_c::~bx_param_string_c()

View File

@ -573,9 +573,8 @@ int bx_real_sim_c::ask_param(const char *pname)
int bx_real_sim_c::ask_filename(const char *filename, int maxlen, const char *prompt, const char *the_default, int flags)
{
BxEvent event;
bx_param_string_c param(NULL, "filename", prompt, "", the_default, maxlen);
flags |= param.IS_FILENAME;
param.set_options(flags);
bx_param_filename_c param(NULL, "filename", prompt, "", the_default, maxlen);
param.set_options(param.get_options() | flags);
event.type = BX_SYNC_EVT_ASK_PARAM;
event.u.param.param = &param;
sim_to_ci_event(&event);

View File

@ -184,6 +184,8 @@ int AskFilename(HWND hwnd, bx_param_filename_c *param, char *buffer)
ofn.lpstrFilter = "Keymap files (*.map)\0*.map\0All files (*.*)\0*.*\0";
} else if (!lstrcmp(ext, "txt")) {
ofn.lpstrFilter = "Text files (*.txt)\0*.txt\0All files (*.*)\0*.*\0";
} else if (!lstrcmp(ext, "bmp")) {
ofn.lpstrFilter = "Windows bitmap files (*.bmp)\0*.bmp\0All files (*.*)\0*.*\0";
} else {
ofn.lpstrFilter = "All files (*.*)\0*.*\0";
}