1 | /* |
1 | /* |
2 | * gen_image.c - Part of psiconv, a PSION 5 file formats converter |
2 | * gen_image.c - Part of psiconv, a PSION 5 file formats converter |
3 | * Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl> |
3 | * Copyright (c) 1999-2005 Frodo Looijaard <frodo@frodo.looijaard.name> |
4 | * |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify |
5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or |
7 | * the Free Software Foundation; either version 2 of the License, or |
8 | * (at your option) any later version. |
8 | * (at your option) any later version. |
… | |
… | |
24 | #include <string.h> |
24 | #include <string.h> |
25 | #include <stdlib.h> |
25 | #include <stdlib.h> |
26 | |
26 | |
27 | #ifdef IMAGEMAGICK |
27 | #ifdef IMAGEMAGICK |
28 | #include "magick-aux.h" |
28 | #include "magick-aux.h" |
29 | #include <magick/magick.h> |
|
|
30 | #endif |
29 | #endif |
31 | |
30 | |
32 | #ifdef DMALLOC |
31 | #ifdef DMALLOC |
33 | #include "dmalloc.h" |
32 | #include "dmalloc.h" |
34 | #endif |
33 | #endif |
35 | |
34 | |
|
|
35 | #ifdef IMAGEMAGICK |
36 | static Image *get_paint_data_section(psiconv_paint_data_section sec); |
36 | static Image *get_paint_data_section(psiconv_paint_data_section sec); |
37 | static void image_to_list(psiconv_list list,Image *image,const char *dest); |
37 | static void image_to_list(psiconv_list list,Image *image,const char *dest); |
38 | static void gen_image_list(const psiconv_config config,psiconv_list list, |
38 | static void gen_image_list(const psiconv_config config,psiconv_list list, |
39 | const psiconv_list sections, const char *dest); |
39 | const psiconv_list sections, const char *dest); |
40 | static void gen_clipart(const psiconv_config config,psiconv_list list, |
40 | static void gen_clipart(const psiconv_config config,psiconv_list list, |
… | |
… | |
89 | ImageInfo *image_info; |
89 | ImageInfo *image_info; |
90 | ExceptionInfo exc; |
90 | ExceptionInfo exc; |
91 | size_t length; |
91 | size_t length; |
92 | char *data; |
92 | char *data; |
93 | int i; |
93 | int i; |
94 | |
94 | |
95 | strcpy(image->magick,dest); |
95 | strcpy(image->magick,dest); |
96 | image_info = CloneImageInfo(NULL); |
96 | image_info = CloneImageInfo(NULL); |
97 | GetExceptionInfo(&exc); |
97 | GetExceptionInfo(&exc); |
98 | data = ImageToBlob(image_info,image,&length,&exc); |
98 | data = ImageToBlob(image_info,image,&length,&exc); |
99 | if (!data || (exc.severity != UndefinedException)) { |
99 | if (!data || (exc.severity != UndefinedException)) { |
… | |
… | |
227 | } else |
227 | } else |
228 | return -1; |
228 | return -1; |
229 | return 0; |
229 | return 0; |
230 | } |
230 | } |
231 | |
231 | |
|
|
232 | #endif |
|
|
233 | |
232 | void init_image(void) |
234 | void init_image(void) |
233 | { |
235 | { |
234 | struct fileformat_s ff; |
236 | struct fileformat_s ff; |
235 | #if IMAGEMAGICK |
237 | #if IMAGEMAGICK |
236 | const MagickInfo *mi; |
238 | const MagickInfo **mi; |
|
|
239 | int i; |
|
|
240 | #if IMAGEMAGICK_API == 100 |
|
|
241 | InitializeMagick(NULL); |
|
|
242 | #endif |
237 | ff.output = gen_image; |
243 | ff.output = gen_image; |
238 | for (mi = GetMagickFileList(); mi ; mi = mi->next) { |
244 | mi = GetMagickFileList(); |
|
|
245 | i = 0; |
|
|
246 | while (mi[i]) { |
239 | if (mi->encoder) { |
247 | if (mi[i]->encoder) { |
240 | ff.name = strdup(mi->name); |
248 | ff.name = strdup(mi[i]->name); |
241 | ff.description = strdup(mi->description); |
249 | ff.description = strdup(mi[i]->description); |
242 | ff.supported_format = FORMAT_CLIPART_SINGLE | FORMAT_MBM_SINGLE | |
250 | ff.supported_format = FORMAT_CLIPART_SINGLE | FORMAT_MBM_SINGLE | |
243 | FORMAT_SKETCH; |
251 | FORMAT_SKETCH; |
244 | if (mi->adjoin) |
252 | if (mi[i]->adjoin) |
245 | ff.supported_format |= FORMAT_MBM_MULTIPLE | FORMAT_CLIPART_MULTIPLE; |
253 | ff.supported_format |= FORMAT_MBM_MULTIPLE | FORMAT_CLIPART_MULTIPLE; |
246 | psiconv_list_add(fileformat_list,&ff); |
254 | psiconv_list_add(fileformat_list,&ff); |
247 | } |
255 | } |
|
|
256 | i++; |
248 | } |
257 | } |
249 | #endif |
258 | #endif |
250 | } |
259 | } |
251 | |
260 | |