/[public]/psiconv/trunk/program/psiconv/gen_image.c
ViewVC logotype

Diff of /psiconv/trunk/program/psiconv/gen_image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 32 Revision 38
19 19
20#include "config.h" 20#include "config.h"
21#include "data.h" 21#include "data.h"
22#include "gen.h" 22#include "gen.h"
23#include <string.h> 23#include <string.h>
24#include "psiconv.h"
24 25
25#if IMAGEMAGICK 26#if IMAGEMAGICK
26#include <magick/magick.h> 27#include <magick/magick.h>
27#endif 28#endif
28 29
29/* This is ridiculously simple using ImageMagick. Without it, it would 30/* This is ridiculously simple using ImageMagick. Without it, it would
30 be somewhat more hard - it will be left for later on */ 31 be quite somewhat harder - it will be left for later on */
31 32
32static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec) 33static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec,
34 const char *dest)
33{ 35{
34#if IMAGEMAGICK 36#if IMAGEMAGICK
35 ImageInfo image_info; 37 ImageInfo image_info;
36 Image *image; 38 Image *image;
37 39
38 image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green, 40 image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green,
39 sec->blue,NULL); 41 sec->blue,NULL);
40 GetImageInfo(&image_info); 42 GetImageInfo(&image_info);
41 image_info.file = of; 43 image_info.file = of;
42 strcpy(image->filename, "bmp:test.bmp"); 44 strcpy(image->magick, dest);
43 WriteImage(&image_info,image); 45 WriteImage(&image_info,image);
44#endif 46#endif
45} 47}
46 48
47static void psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f) 49static int psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest)
48{ 50{
49 psiconv_paint_data_section section; 51 psiconv_paint_data_section section;
52#if IMAGEMAGICK
53 MagickInfo *mi = GetMagickInfo(dest);
54#endif
50 if (psiconv_list_length(f->sections) >= 1) { 55 if (psiconv_list_length(f->sections) == 1) {
51 section = psiconv_list_get(f->sections,0); 56 section = psiconv_list_get(f->sections,0);
52 gen_paint_data_section(of,section); 57 gen_paint_data_section(of,section,dest);
53 } 58 return 0;
59#if IMAGEMAGICK
60 } else if ((mi->adjoin) && (psiconv_list_length(f->sections) >= 1)) {
61 /* Not yet supported... */
62 return -1;
63#endif
64 } else
65 return -1;
54} 66}
55 67
56static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f) 68static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f,
69 const char * dest)
57{ 70{
58 gen_paint_data_section(of,f->sketch_sec->picture); 71 gen_paint_data_section(of,f->sketch_sec->picture,dest);
59} 72}
60 73
61void psiconv_gen_image(FILE * of, psiconv_file file) 74static int psiconv_gen_image(FILE * of, const psiconv_file file,
75 const char *dest)
62{ 76{
63 if (file->type == psiconv_mbm_file) 77 if (file->type == psiconv_mbm_file)
64 psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file); 78 return psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest);
65 else if (file->type == psiconv_sketch_file) 79 else if (file->type == psiconv_sketch_file) {
66 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file); 80 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest);
81 return 0;
82 } else
83 return -1;
67} 84}
68 85
86void init_image(void)
87{
88 struct psiconv_fileformat ff;
89#if IMAGEMAGICK
90 MagickInfo *mi;
91 ff.output = psiconv_gen_image;
92 for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) {
93 if (mi->encoder) {
94 ff.name = strdup(mi->tag);
95 ff.description = strdup(mi->description);
96 psiconv_list_add(fileformat_list,&ff);
97 }
98 }
99#endif
100}
101

Legend:
Removed from v.32  
changed lines
  Added in v.38

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26