--- psiconv/trunk/program/psiconv/gen_image.c 1999/12/02 20:09:59 38 +++ psiconv/trunk/program/psiconv/gen_image.c 1999/12/02 23:36:45 39 @@ -30,45 +30,64 @@ /* This is ridiculously simple using ImageMagick. Without it, it would be quite somewhat harder - it will be left for later on */ -static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec, - const char *dest) +static Image *get_paint_data_section(psiconv_paint_data_section sec) { -#if IMAGEMAGICK - ImageInfo image_info; Image *image; - image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green, sec->blue,NULL); - GetImageInfo(&image_info); - image_info.file = of; - strcpy(image->magick, dest); - WriteImage(&image_info,image); -#endif + return image; } + static int psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest) { - psiconv_paint_data_section section; #if IMAGEMAGICK + psiconv_paint_data_section section; MagickInfo *mi = GetMagickInfo(dest); + ImageInfo image_info; + Image *image = NULL; + Image *last_image = NULL; + Image *this_image; + int i; + + if ((psiconv_list_length(f->sections) < 1) || + ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) #endif - if (psiconv_list_length(f->sections) == 1) { - section = psiconv_list_get(f->sections,0); - gen_paint_data_section(of,section,dest); - return 0; -#if IMAGEMAGICK - } else if ((mi->adjoin) && (psiconv_list_length(f->sections) >= 1)) { - /* Not yet supported... */ return -1; +#if IMAGEMAGICK + for (i = 0; i < psiconv_list_length(f->sections); i++) { + section = psiconv_list_get(f->sections,0); + this_image = get_paint_data_section(section); + if (! image) { + image = image; + last_image = image; + } else { + last_image->next=this_image; + this_image->previous=last_image; + } + } + + GetImageInfo(&image_info); + image_info.file = of; + strcpy(image->magick, dest); + WriteImage(&image_info,image); + return 0; #endif - } else - return -1; } -static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f, - const char * dest) +static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f, + const char *dest) { - gen_paint_data_section(of,f->sketch_sec->picture,dest); +#if IMAGEMAGICK + ImageInfo image_info; + Image *image; + + image = get_paint_data_section(f->sketch_sec->picture); + GetImageInfo(&image_info); + image_info.file = of; + strcpy(image->magick, dest); + WriteImage(&image_info,image); +#endif } static int psiconv_gen_image(FILE * of, const psiconv_file file,