/[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 40 - (hide annotations)
Fri Dec 3 00:15:17 1999 UTC (24 years, 4 months ago) by frodo
File MIME type: text/plain
File size: 3406 byte(s)
(Frodo) Multiple images in a file are now supported.

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 40 section = psiconv_list_get(f->sections,i);
60 frodo 39 this_image = get_paint_data_section(section);
61     if (! image) {
62 frodo 40 image = this_image;
63 frodo 39 last_image = image;
64     } else {
65     last_image->next=this_image;
66     this_image->previous=last_image;
67 frodo 40 this_image->scene=i;
68     last_image=this_image;
69 frodo 39 }
70     }
71 frodo 40
72 frodo 39 GetImageInfo(&image_info);
73     image_info.file = of;
74     strcpy(image->magick, dest);
75 frodo 40 image_info.adjoin=1;
76 frodo 39 WriteImage(&image_info,image);
77     return 0;
78 frodo 38 #endif
79 frodo 32 }
80    
81 frodo 39 static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f,
82     const char *dest)
83 frodo 32 {
84 frodo 39 #if IMAGEMAGICK
85     ImageInfo image_info;
86     Image *image;
87    
88     image = get_paint_data_section(f->sketch_sec->picture);
89     GetImageInfo(&image_info);
90     image_info.file = of;
91     strcpy(image->magick, dest);
92     WriteImage(&image_info,image);
93     #endif
94 frodo 32 }
95    
96 frodo 34 static int psiconv_gen_image(FILE * of, const psiconv_file file,
97     const char *dest)
98 frodo 32 {
99 frodo 38 if (file->type == psiconv_mbm_file)
100     return psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest);
101     else if (file->type == psiconv_sketch_file) {
102 frodo 34 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest);
103     return 0;
104     } else
105     return -1;
106 frodo 32 }
107    
108 frodo 34 void init_image(void)
109     {
110     struct psiconv_fileformat ff;
111     #if IMAGEMAGICK
112     MagickInfo *mi;
113     ff.output = psiconv_gen_image;
114     for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) {
115     if (mi->encoder) {
116     ff.name = strdup(mi->tag);
117     ff.description = strdup(mi->description);
118     psiconv_list_add(fileformat_list,&ff);
119     }
120     }
121     #endif
122     }
123    

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