… | |
… | |
16 | * along with this program; if not, write to the Free Software |
16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
18 | */ |
18 | */ |
19 | |
19 | |
20 | #include "config.h" |
20 | #include "config.h" |
21 | #include "data.h" |
21 | #include "psiconv/data.h" |
22 | #include "gen.h" |
22 | #include "gen.h" |
23 | #include <string.h> |
23 | #include <string.h> |
24 | #include "psiconv.h" |
24 | #include "psiconv.h" |
25 | |
25 | |
26 | #if IMAGEMAGICK |
26 | #if IMAGEMAGICK |
… | |
… | |
57 | *p++ = *red++; |
57 | *p++ = *red++; |
58 | *p++ = *green++; |
58 | *p++ = *green++; |
59 | *p++ = *blue++; |
59 | *p++ = *blue++; |
60 | } |
60 | } |
61 | } |
61 | } |
|
|
62 | |
62 | image = ConstituteImage(sec->xsize,sec->ysize,"RGB",FloatPixel,pixel,&exc); |
63 | image = ConstituteImage(sec->xsize,sec->ysize,"RGB",FloatPixel,pixel,&exc); |
63 | if (! image) { |
64 | if (! image) { |
64 | MagickError(exc.severity,exc.message,exc.qualifier); |
65 | MagickError(exc.severity,exc.message,exc.qualifier); |
65 | } |
66 | } |
66 | free(pixel); |
67 | free(pixel); |
… | |
… | |
102 | } |
103 | } |
103 | |
104 | |
104 | GetExceptionInfo(&exc); |
105 | GetExceptionInfo(&exc); |
105 | image_info = CloneImageInfo(NULL); |
106 | image_info = CloneImageInfo(NULL); |
106 | set_filename(image->filename,dest,filename); |
107 | set_filename(image->filename,dest,filename); |
|
|
108 | if (image->next) |
107 | images = CoalesceImages(image,&exc); |
109 | images = CoalesceImages(image,&exc); |
|
|
110 | else |
|
|
111 | images = image; |
108 | if (! images) |
112 | if (! images) |
109 | CatchImageException(image); |
113 | CatchImageException(image); |
110 | |
114 | |
111 | status = WriteImage(image_info,images); |
115 | status = WriteImage(image_info,images); |
112 | if (!status) |
116 | if (!status) |
113 | CatchImageException(images); |
117 | CatchImageException(images); |
114 | DestroyImageInfo(image_info); |
118 | DestroyImageInfo(image_info); |
|
|
119 | if (image != images) |
115 | DestroyImages(image); |
120 | DestroyImages(image); |
116 | DestroyImages(images); |
121 | DestroyImages(images); |
117 | return 0; |
122 | return 0; |
118 | #endif |
123 | #endif |
119 | } |
124 | } |
120 | |
125 | |
121 | static int psiconv_gen_image_mbm(const char *filename, psiconv_mbm_f f, |
126 | static int psiconv_gen_image_mbm(const char *filename, psiconv_mbm_f f, |
122 | const char *dest) |
127 | const char *dest) |
123 | { |
128 | { |
|
|
129 | |
124 | #if IMAGEMAGICK |
130 | #if IMAGEMAGICK |
125 | psiconv_paint_data_section section; |
131 | psiconv_paint_data_section section; |
126 | MagickInfo *mi = GetMagickInfo(dest); |
132 | MagickInfo *mi = GetMagickInfo(dest); |
127 | ImageInfo *image_info; |
133 | ImageInfo *image_info; |
128 | Image *image = NULL; |
134 | Image *image = NULL; |
129 | Image *last_image = NULL; |
135 | Image *last_image = NULL; |
130 | Image *this_image, *images; |
136 | Image *this_image, *images; |
131 | ExceptionInfo exc; |
137 | ExceptionInfo exc; |
132 | int i; |
138 | int i; |
133 | unsigned int status; |
139 | unsigned int status; |
134 | |
140 | |
135 | if ((psiconv_list_length(f->sections) < 1) || |
141 | if ((psiconv_list_length(f->sections) < 1) || |
136 | ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) |
142 | ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) |
137 | #endif |
143 | #endif |
138 | return -1; |
144 | return -1; |
139 | #if IMAGEMAGICK |
145 | #if IMAGEMAGICK |
|
|
146 | |
140 | for (i = 0; i < psiconv_list_length(f->sections); i++) { |
147 | for (i = 0; i < psiconv_list_length(f->sections); i++) { |
141 | section = psiconv_list_get(f->sections,i); |
148 | section = psiconv_list_get(f->sections,i); |
142 | this_image = get_paint_data_section(section); |
149 | this_image = get_paint_data_section(section); |
143 | if (! image) { |
150 | if (! image) { |
144 | image = this_image; |
151 | image = this_image; |
145 | this_image->scene=1; |
|
|
146 | } else { |
152 | } else { |
147 | last_image->next=this_image; |
153 | last_image->next=this_image; |
148 | this_image->previous=last_image; |
154 | this_image->previous=last_image; |
149 | } |
155 | } |
150 | last_image = this_image; |
156 | last_image = this_image; |
151 | } |
157 | } |
152 | |
158 | |
153 | GetExceptionInfo(&exc); |
159 | GetExceptionInfo(&exc); |
154 | image_info = CloneImageInfo(NULL); |
160 | image_info = CloneImageInfo(NULL); |
155 | set_filename(image->filename,dest,filename); |
161 | set_filename(image->filename,dest,filename); |
|
|
162 | if (image->next) |
156 | images = CoalesceImages(image,&exc); |
163 | images = CoalesceImages(image,&exc); |
|
|
164 | else |
|
|
165 | images = image; |
157 | if (! images) |
166 | if (! images) |
158 | CatchImageException(image); |
167 | CatchImageException(image); |
159 | |
168 | |
160 | status = WriteImage(image_info,images); |
169 | status = WriteImage(image_info,images); |
161 | if (!status) |
170 | if (!status) |
162 | CatchImageException(images); |
171 | CatchImageException(images); |
163 | DestroyImageInfo(image_info); |
172 | DestroyImageInfo(image_info); |
|
|
173 | if (image != images) |
164 | DestroyImages(image); |
174 | DestroyImages(image); |
165 | DestroyImages(images); |
175 | DestroyImages(images); |
166 | return 0; |
176 | return 0; |
167 | #endif |
177 | #endif |
168 | } |
178 | } |
169 | |
179 | |
… | |
… | |
186 | static int psiconv_gen_image(const char * filename, const psiconv_file file, |
196 | static int psiconv_gen_image(const char * filename, const psiconv_file file, |
187 | const char *dest) |
197 | const char *dest) |
188 | { |
198 | { |
189 | if (file->type == psiconv_mbm_file) |
199 | if (file->type == psiconv_mbm_file) |
190 | psiconv_gen_image_mbm(filename,(psiconv_mbm_f) file->file,dest); |
200 | psiconv_gen_image_mbm(filename,(psiconv_mbm_f) file->file,dest); |
191 | if (file->type == psiconv_clipart_file) |
201 | else if (file->type == psiconv_clipart_file) |
192 | psiconv_gen_image_clipart(filename,(psiconv_clipart_f) file->file,dest); |
202 | psiconv_gen_image_clipart(filename,(psiconv_clipart_f) file->file,dest); |
193 | else if (file->type == psiconv_sketch_file) { |
203 | else if (file->type == psiconv_sketch_file) { |
194 | psiconv_gen_image_sketch(filename,(psiconv_sketch_f) file->file,dest); |
204 | psiconv_gen_image_sketch(filename,(psiconv_sketch_f) file->file,dest); |
195 | } else |
205 | } else |
196 | return -1; |
206 | return -1; |
197 | return 0; |
207 | return 0; |
198 | } |
208 | } |
199 | |
209 | |
200 | void init_image(void) |
210 | void init_image(void) |
201 | { |
211 | { |
202 | struct psiconv_fileformat ff; |
212 | struct psiconv_fileformat_s ff; |
203 | #if IMAGEMAGICK |
213 | #if IMAGEMAGICK |
204 | MagickInfo *mi; |
214 | MagickInfo *mi; |
205 | ff.output = psiconv_gen_image; |
215 | ff.output = psiconv_gen_image; |
206 | for (mi = GetMagickFileList(); mi ; mi = mi->next) { |
216 | for (mi = GetMagickFileList(); mi ; mi = mi->next) { |
207 | if (mi->encoder) { |
217 | if (mi->encoder) { |