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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 39 - (hide annotations)
Thu Dec 2 23:36:45 1999 UTC (24 years, 4 months ago) by frodo
File MIME type: text/plain
File size: 3327 byte(s)
(Frodo) Multiple pictures conversion should be in. But no test-MBMs yet :-(

1 frodo 32 /*
2     * gen_image.c - Part of psiconv, a PSION 5 file formats converter
3     * Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl>
4     *
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
7     * the Free Software Foundation; either version 2 of the License, or
8     * (at your option) any later version.
9     *
10     * This program is distributed in the hope that it will be useful,
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     * GNU General Public License for more details.
14     *
15     * You should have received a copy of the GNU General Public License
16     * along with this program; if not, write to the Free Software
17     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18     */
19    
20     #include "config.h"
21     #include "data.h"
22     #include "gen.h"
23     #include <string.h>
24 frodo 34 #include "psiconv.h"
25 frodo 32
26     #if IMAGEMAGICK
27     #include <magick/magick.h>
28     #endif
29    
30     /* This is ridiculously simple using ImageMagick. Without it, it would
31 frodo 34 be quite somewhat harder - it will be left for later on */
32 frodo 32
33 frodo 39 static Image *get_paint_data_section(psiconv_paint_data_section sec)
34 frodo 32 {
35     Image *image;
36     image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green,
37     sec->blue,NULL);
38 frodo 39 return image;
39 frodo 32 }
40    
41 frodo 39
42 frodo 38 static int psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest)
43 frodo 32 {
44 frodo 39 #if IMAGEMAGICK
45 frodo 32 psiconv_paint_data_section section;
46 frodo 38 MagickInfo *mi = GetMagickInfo(dest);
47 frodo 39 ImageInfo image_info;
48     Image *image = NULL;
49     Image *last_image = NULL;
50     Image *this_image;
51     int i;
52    
53     if ((psiconv_list_length(f->sections) < 1) ||
54     ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin)))
55 frodo 38 #endif
56 frodo 39 return -1;
57     #if IMAGEMAGICK
58     for (i = 0; i < psiconv_list_length(f->sections); i++) {
59 frodo 32 section = psiconv_list_get(f->sections,0);
60 frodo 39 this_image = get_paint_data_section(section);
61     if (! image) {
62     image = image;
63     last_image = image;
64     } else {
65     last_image->next=this_image;
66     this_image->previous=last_image;
67     }
68     }
69    
70     GetImageInfo(&image_info);
71     image_info.file = of;
72     strcpy(image->magick, dest);
73     WriteImage(&image_info,image);
74     return 0;
75 frodo 38 #endif
76 frodo 32 }
77    
78 frodo 39 static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f,
79     const char *dest)
80 frodo 32 {
81 frodo 39 #if IMAGEMAGICK
82     ImageInfo image_info;
83     Image *image;
84    
85     image = get_paint_data_section(f->sketch_sec->picture);
86     GetImageInfo(&image_info);
87     image_info.file = of;
88     strcpy(image->magick, dest);
89     WriteImage(&image_info,image);
90     #endif
91 frodo 32 }
92    
93 frodo 34 static int psiconv_gen_image(FILE * of, const psiconv_file file,
94     const char *dest)
95 frodo 32 {
96 frodo 38 if (file->type == psiconv_mbm_file)
97     return psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest);
98     else if (file->type == psiconv_sketch_file) {
99 frodo 34 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest);
100     return 0;
101     } else
102     return -1;
103 frodo 32 }
104    
105 frodo 34 void init_image(void)
106     {
107     struct psiconv_fileformat ff;
108     #if IMAGEMAGICK
109     MagickInfo *mi;
110     ff.output = psiconv_gen_image;
111     for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) {
112     if (mi->encoder) {
113     ff.name = strdup(mi->tag);
114     ff.description = strdup(mi->description);
115     psiconv_list_add(fileformat_list,&ff);
116     }
117     }
118     #endif
119     }
120    

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