… | |
… | |
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 | |
32 | static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec) |
33 | static 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 | |
47 | static void psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f) |
49 | static void 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; |
50 | if (psiconv_list_length(f->sections) >= 1) { |
52 | if (psiconv_list_length(f->sections) >= 1) { |
51 | section = psiconv_list_get(f->sections,0); |
53 | section = psiconv_list_get(f->sections,0); |
52 | gen_paint_data_section(of,section); |
54 | gen_paint_data_section(of,section,dest); |
53 | } |
55 | } |
54 | } |
56 | } |
55 | |
57 | |
56 | static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f) |
58 | static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f, |
|
|
59 | const char * dest) |
57 | { |
60 | { |
58 | gen_paint_data_section(of,f->sketch_sec->picture); |
61 | gen_paint_data_section(of,f->sketch_sec->picture,dest); |
59 | } |
62 | } |
60 | |
63 | |
61 | void psiconv_gen_image(FILE * of, psiconv_file file) |
64 | static int psiconv_gen_image(FILE * of, const psiconv_file file, |
|
|
65 | const char *dest) |
62 | { |
66 | { |
63 | if (file->type == psiconv_mbm_file) |
67 | if (file->type == psiconv_mbm_file) { |
64 | psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file); |
68 | psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest); |
|
|
69 | return 0; |
65 | else if (file->type == psiconv_sketch_file) |
70 | } else if (file->type == psiconv_sketch_file) { |
66 | psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file); |
71 | psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest); |
|
|
72 | return 0; |
|
|
73 | } else |
|
|
74 | return -1; |
67 | } |
75 | } |
68 | |
76 | |
|
|
77 | void init_image(void) |
|
|
78 | { |
|
|
79 | struct psiconv_fileformat ff; |
|
|
80 | #if IMAGEMAGICK |
|
|
81 | MagickInfo *mi; |
|
|
82 | ff.output = psiconv_gen_image; |
|
|
83 | for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) { |
|
|
84 | if (mi->encoder) { |
|
|
85 | ff.name = strdup(mi->tag); |
|
|
86 | ff.description = strdup(mi->description); |
|
|
87 | psiconv_list_add(fileformat_list,&ff); |
|
|
88 | } |
|
|
89 | } |
|
|
90 | #endif |
|
|
91 | } |
|
|
92 | |