--- psiconv/trunk/program/psiconv/gen_image.c 1999/12/02 23:36:45 39 +++ psiconv/trunk/program/psiconv/gen_image.c 2000/10/04 19:02:04 52 @@ -24,20 +24,80 @@ #include "psiconv.h" #if IMAGEMAGICK +#include "magick-aux.h" #include -#endif /* This is ridiculously simple using ImageMagick. Without it, it would - be quite somewhat harder - it will be left for later on */ + be quite somewhat harder - it will be left for later on. + Note that we ignore any errors. Dangerous... */ static Image *get_paint_data_section(psiconv_paint_data_section sec) { Image *image; - image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green, - sec->blue,NULL); + float *pixel, *p, *red, *green, *blue; + int x,y; + ExceptionInfo *exc; + + GetExceptionInfo(exc); + red = sec->red; + green = sec->green; + blue = sec->blue; + p = pixel = malloc(sec->xsize * sec->ysize * 3 * sizeof(float)); + for (y = 0; y < sec->ysize; y++) { + for (x = 0; x < sec->xsize; x++) { + *p++ = *red++; + *p++ = *green++; + *p++ = *blue++; + } + } + image = ConstituteImage(sec->xsize,sec->ysize,"RGB",FloatPixel,pixel,exc); + free(pixel); + DestroyExceptionInfo(exc); + return image; } +#endif + +static int psiconv_gen_image_clipart(FILE *of, psiconv_clipart_f f, + const char *dest) +{ +#if IMAGEMAGICK + psiconv_clipart_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 + return -1; +#if IMAGEMAGICK + for (i = 0; i < psiconv_list_length(f->sections); i++) { + section = psiconv_list_get(f->sections,i); + this_image = get_paint_data_section(section->picture); + if (! image) { + image = this_image; + last_image = image; + } else { + last_image->next=this_image; + this_image->previous=last_image; + this_image->scene=i; + last_image=this_image; + } + } + + GetImageInfo(&image_info); + image_info.file = of; + strcpy(image->magick, dest); + image_info.adjoin=1; + WriteImage(&image_info,image); + return 0; +#endif +} static int psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest) { @@ -56,20 +116,23 @@ return -1; #if IMAGEMAGICK for (i = 0; i < psiconv_list_length(f->sections); i++) { - section = psiconv_list_get(f->sections,0); + section = psiconv_list_get(f->sections,i); this_image = get_paint_data_section(section); if (! image) { - image = image; + image = this_image; last_image = image; } else { last_image->next=this_image; this_image->previous=last_image; + this_image->scene=i; + last_image=this_image; } } - + GetImageInfo(&image_info); image_info.file = of; strcpy(image->magick, dest); + image_info.adjoin=1; WriteImage(&image_info,image); return 0; #endif @@ -95,6 +158,8 @@ { if (file->type == psiconv_mbm_file) return psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest); + if (file->type == psiconv_clipart_file) + return psiconv_gen_image_clipart(of,(psiconv_clipart_f) file->file,dest); else if (file->type == psiconv_sketch_file) { psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest); return 0; @@ -108,7 +173,7 @@ #if IMAGEMAGICK MagickInfo *mi; ff.output = psiconv_gen_image; - for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) { + for (mi = GetMagickFileList(); mi ; mi = mi->next) { if (mi->encoder) { ff.name = strdup(mi->tag); ff.description = strdup(mi->description);