… | |
… | |
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.reason,exc.description); |
65 | } |
66 | } |
66 | free(pixel); |
67 | free(pixel); |
67 | |
68 | |
68 | return image; |
69 | return image; |
69 | } |
70 | } |
… | |
… | |
73 | static int psiconv_gen_image_clipart(const char *filename, psiconv_clipart_f f, |
74 | static int psiconv_gen_image_clipart(const char *filename, psiconv_clipart_f f, |
74 | const char *dest) |
75 | const char *dest) |
75 | { |
76 | { |
76 | #if IMAGEMAGICK |
77 | #if IMAGEMAGICK |
77 | psiconv_clipart_section section; |
78 | psiconv_clipart_section section; |
78 | MagickInfo *mi = GetMagickInfo(dest); |
79 | MagickInfo *mi; |
79 | ImageInfo *image_info; |
80 | ImageInfo *image_info; |
80 | Image *image = NULL; |
81 | Image *image = NULL; |
81 | Image *last_image = NULL; |
82 | Image *last_image = NULL; |
82 | Image *this_image, *images; |
83 | Image *this_image, *images; |
83 | ExceptionInfo exc; |
84 | ExceptionInfo exc; |
84 | int i; |
85 | int i; |
85 | unsigned int status; |
86 | unsigned int status; |
|
|
87 | |
|
|
88 | GetExceptionInfo(&exc); |
|
|
89 | if (!(mi = GetMagickInfo(dest,&exc))) |
|
|
90 | return -1; |
86 | |
91 | |
87 | if ((psiconv_list_length(f->sections) < 1) || |
92 | if ((psiconv_list_length(f->sections) < 1) || |
88 | ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) |
93 | ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) |
89 | #endif |
94 | #endif |
90 | return -1; |
95 | return -1; |
… | |
… | |
99 | this_image->previous=last_image; |
104 | this_image->previous=last_image; |
100 | } |
105 | } |
101 | last_image = this_image; |
106 | last_image = this_image; |
102 | } |
107 | } |
103 | |
108 | |
104 | GetExceptionInfo(&exc); |
|
|
105 | image_info = CloneImageInfo(NULL); |
109 | image_info = CloneImageInfo(NULL); |
106 | set_filename(image->filename,dest,filename); |
110 | set_filename(image->filename,dest,filename); |
|
|
111 | if (image->next) |
107 | images = CoalesceImages(image,&exc); |
112 | images = CoalesceImages(image,&exc); |
|
|
113 | else |
|
|
114 | images = image; |
108 | if (! images) |
115 | if (! images) |
109 | CatchImageException(image); |
116 | CatchImageException(image); |
110 | |
117 | |
111 | status = WriteImage(image_info,images); |
118 | status = WriteImage(image_info,images); |
112 | if (!status) |
119 | if (!status) |
113 | CatchImageException(images); |
120 | CatchImageException(images); |
114 | DestroyImageInfo(image_info); |
121 | DestroyImageInfo(image_info); |
|
|
122 | if (image != images) |
115 | DestroyImages(image); |
123 | DestroyImages(image); |
116 | DestroyImages(images); |
124 | DestroyImages(images); |
117 | return 0; |
125 | return 0; |
118 | #endif |
126 | #endif |
119 | } |
127 | } |
120 | |
128 | |
121 | static int psiconv_gen_image_mbm(const char *filename, psiconv_mbm_f f, |
129 | static int psiconv_gen_image_mbm(const char *filename, psiconv_mbm_f f, |
122 | const char *dest) |
130 | const char *dest) |
123 | { |
131 | { |
|
|
132 | |
124 | #if IMAGEMAGICK |
133 | #if IMAGEMAGICK |
125 | psiconv_paint_data_section section; |
134 | psiconv_paint_data_section section; |
126 | MagickInfo *mi = GetMagickInfo(dest); |
135 | MagickInfo *mi; |
127 | ImageInfo *image_info; |
136 | ImageInfo *image_info; |
128 | Image *image = NULL; |
137 | Image *image = NULL; |
129 | Image *last_image = NULL; |
138 | Image *last_image = NULL; |
130 | Image *this_image, *images; |
139 | Image *this_image, *images; |
131 | ExceptionInfo exc; |
140 | ExceptionInfo exc; |
132 | int i; |
141 | int i; |
133 | unsigned int status; |
142 | unsigned int status; |
134 | |
143 | |
|
|
144 | GetExceptionInfo(&exc); |
|
|
145 | if (!(mi = GetMagickInfo(dest,&exc))) |
|
|
146 | return -1; |
|
|
147 | |
135 | if ((psiconv_list_length(f->sections) < 1) || |
148 | if ((psiconv_list_length(f->sections) < 1) || |
136 | ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) |
149 | ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin))) |
137 | #endif |
150 | #endif |
138 | return -1; |
151 | return -1; |
139 | #if IMAGEMAGICK |
152 | #if IMAGEMAGICK |
|
|
153 | |
140 | for (i = 0; i < psiconv_list_length(f->sections); i++) { |
154 | for (i = 0; i < psiconv_list_length(f->sections); i++) { |
141 | section = psiconv_list_get(f->sections,i); |
155 | section = psiconv_list_get(f->sections,i); |
142 | this_image = get_paint_data_section(section); |
156 | this_image = get_paint_data_section(section); |
143 | if (! image) { |
157 | if (! image) { |
144 | image = this_image; |
158 | image = this_image; |
145 | this_image->scene=1; |
|
|
146 | } else { |
159 | } else { |
147 | last_image->next=this_image; |
160 | last_image->next=this_image; |
148 | this_image->previous=last_image; |
161 | this_image->previous=last_image; |
149 | } |
162 | } |
150 | last_image = this_image; |
163 | last_image = this_image; |
151 | } |
164 | } |
152 | |
165 | |
153 | GetExceptionInfo(&exc); |
|
|
154 | image_info = CloneImageInfo(NULL); |
166 | image_info = CloneImageInfo(NULL); |
155 | set_filename(image->filename,dest,filename); |
167 | set_filename(image->filename,dest,filename); |
|
|
168 | if (image->next) |
156 | images = CoalesceImages(image,&exc); |
169 | images = CoalesceImages(image,&exc); |
|
|
170 | else |
|
|
171 | images = image; |
157 | if (! images) |
172 | if (! images) |
158 | CatchImageException(image); |
173 | CatchImageException(image); |
159 | |
174 | |
160 | status = WriteImage(image_info,images); |
175 | status = WriteImage(image_info,images); |
161 | if (!status) |
176 | if (!status) |
162 | CatchImageException(images); |
177 | CatchImageException(images); |
163 | DestroyImageInfo(image_info); |
178 | DestroyImageInfo(image_info); |
|
|
179 | if (image != images) |
164 | DestroyImages(image); |
180 | DestroyImages(image); |
165 | DestroyImages(images); |
181 | DestroyImages(images); |
166 | return 0; |
182 | return 0; |
167 | #endif |
183 | #endif |
168 | } |
184 | } |
169 | |
185 | |
… | |
… | |
186 | static int psiconv_gen_image(const char * filename, const psiconv_file file, |
202 | static int psiconv_gen_image(const char * filename, const psiconv_file file, |
187 | const char *dest) |
203 | const char *dest) |
188 | { |
204 | { |
189 | if (file->type == psiconv_mbm_file) |
205 | if (file->type == psiconv_mbm_file) |
190 | psiconv_gen_image_mbm(filename,(psiconv_mbm_f) file->file,dest); |
206 | psiconv_gen_image_mbm(filename,(psiconv_mbm_f) file->file,dest); |
191 | if (file->type == psiconv_clipart_file) |
207 | else if (file->type == psiconv_clipart_file) |
192 | psiconv_gen_image_clipart(filename,(psiconv_clipart_f) file->file,dest); |
208 | psiconv_gen_image_clipart(filename,(psiconv_clipart_f) file->file,dest); |
193 | else if (file->type == psiconv_sketch_file) { |
209 | else if (file->type == psiconv_sketch_file) { |
194 | psiconv_gen_image_sketch(filename,(psiconv_sketch_f) file->file,dest); |
210 | psiconv_gen_image_sketch(filename,(psiconv_sketch_f) file->file,dest); |
195 | } else |
211 | } else |
196 | return -1; |
212 | return -1; |