/[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 38 - (hide annotations)
Thu Dec 2 20:09:59 1999 UTC (24 years, 4 months ago) by frodo
File MIME type: text/plain
File size: 2959 byte(s)
(Frodo) Preparations for multiple images output

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 34 static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec,
34     const char *dest)
35 frodo 32 {
36     #if IMAGEMAGICK
37     ImageInfo image_info;
38     Image *image;
39    
40     image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green,
41     sec->blue,NULL);
42     GetImageInfo(&image_info);
43     image_info.file = of;
44 frodo 34 strcpy(image->magick, dest);
45 frodo 32 WriteImage(&image_info,image);
46     #endif
47     }
48    
49 frodo 38 static int psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest)
50 frodo 32 {
51     psiconv_paint_data_section section;
52 frodo 38 #if IMAGEMAGICK
53     MagickInfo *mi = GetMagickInfo(dest);
54     #endif
55     if (psiconv_list_length(f->sections) == 1) {
56 frodo 32 section = psiconv_list_get(f->sections,0);
57 frodo 34 gen_paint_data_section(of,section,dest);
58 frodo 38 return 0;
59     #if IMAGEMAGICK
60     } else if ((mi->adjoin) && (psiconv_list_length(f->sections) >= 1)) {
61     /* Not yet supported... */
62     return -1;
63     #endif
64     } else
65     return -1;
66 frodo 32 }
67    
68 frodo 34 static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f,
69     const char * dest)
70 frodo 32 {
71 frodo 34 gen_paint_data_section(of,f->sketch_sec->picture,dest);
72 frodo 32 }
73    
74 frodo 34 static int psiconv_gen_image(FILE * of, const psiconv_file file,
75     const char *dest)
76 frodo 32 {
77 frodo 38 if (file->type == psiconv_mbm_file)
78     return psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest);
79     else if (file->type == psiconv_sketch_file) {
80 frodo 34 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest);
81     return 0;
82     } else
83     return -1;
84 frodo 32 }
85    
86 frodo 34 void init_image(void)
87     {
88     struct psiconv_fileformat ff;
89     #if IMAGEMAGICK
90     MagickInfo *mi;
91     ff.output = psiconv_gen_image;
92     for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) {
93     if (mi->encoder) {
94     ff.name = strdup(mi->tag);
95     ff.description = strdup(mi->description);
96     psiconv_list_add(fileformat_list,&ff);
97     }
98     }
99     #endif
100     }
101    

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