--- psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/25 22:08:48 170 +++ psiconv/trunk/lib/psiconv/generate_driver.c 2003/11/26 20:56:17 171 @@ -65,11 +65,15 @@ if ((res =psiconv_write_sketch_file(config,*buf, (psiconv_sketch_f) (value->file)))) goto ERROR; -#if 0 } else if (value->type == psiconv_mbm_file) { + if ((res = psiconv_write_header_section(config,*buf,PSICONV_ID_PSION5, + PSICONV_ID_MBM_FILE, + 0x00000000))) + goto ERROR; if ((res =psiconv_write_mbm_file(config,*buf, (psiconv_mbm_f) (value->file)))) goto ERROR; +#if 0 } else if (value->type == psiconv_clipart_file) { if ((res =psiconv_write_clipart_file(config,*buf, (psiconv_clipart_f) (value->file)))) @@ -333,3 +337,51 @@ ERROR1: return res; } + +int psiconv_write_mbm_file(const psiconv_config config, + psiconv_buffer buf,psiconv_mbm_f value) +{ + int res,i; + psiconv_jumptable_section jumptable; + psiconv_u32 *entry,id,table_id; + psiconv_paint_data_section section; + + if (!value) { + psiconv_warn(config,0,0,"Null MBM file"); + return -PSICONV_E_GENERATE; + } + + if (!(jumptable = psiconv_list_new(sizeof(*entry)))) { + res = -PSICONV_E_NOMEM; + goto ERROR1; + } + + table_id = psiconv_buffer_unique_id(); + if ((res = psiconv_buffer_add_reference(buf,table_id))) + goto ERROR2; + + for (i = 0; i < psiconv_list_length(value->sections); i++) { + if (!(section = psiconv_list_get(value->sections,i))) { + psiconv_warn(config,0,0,"Massive memory corruption"); + res = -PSICONV_E_NOMEM; + goto ERROR2; + } + id = psiconv_buffer_unique_id(); + psiconv_list_add(jumptable,&id); + if ((res = psiconv_buffer_add_target(buf,id))) + goto ERROR2; + if ((res = psiconv_write_paint_data_section(config,buf,section))) + goto ERROR2; + } + + if ((res = psiconv_buffer_add_target(buf,table_id))) + goto ERROR2; + if ((res = psiconv_write_jumptable_section(config,buf,jumptable))) + goto ERROR2; + + +ERROR2: + psiconv_list_free(jumptable); +ERROR1: + return res; +}