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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34 - (show annotations)
Thu Dec 2 17:18:55 1999 UTC (20 years ago) by frodo
File MIME type: text/plain
File size: 2732 byte(s)
(Frodo) Full ImageLib support!

To do:
  * More than one picture in a file
  * Special features like clipping

1 /*
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 #include "psiconv.h"
25
26 #if IMAGEMAGICK
27 #include <magick/magick.h>
28 #endif
29
30 /* This is ridiculously simple using ImageMagick. Without it, it would
31 be quite somewhat harder - it will be left for later on */
32
33 static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec,
34 const char *dest)
35 {
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 strcpy(image->magick, dest);
45 WriteImage(&image_info,image);
46 #endif
47 }
48
49 static void psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest)
50 {
51 psiconv_paint_data_section section;
52 if (psiconv_list_length(f->sections) >= 1) {
53 section = psiconv_list_get(f->sections,0);
54 gen_paint_data_section(of,section,dest);
55 }
56 }
57
58 static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f,
59 const char * dest)
60 {
61 gen_paint_data_section(of,f->sketch_sec->picture,dest);
62 }
63
64 static int psiconv_gen_image(FILE * of, const psiconv_file file,
65 const char *dest)
66 {
67 if (file->type == psiconv_mbm_file) {
68 psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest);
69 return 0;
70 } else if (file->type == psiconv_sketch_file) {
71 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest);
72 return 0;
73 } else
74 return -1;
75 }
76
77 void init_image(void)
78 {
79 struct psiconv_fileformat ff;
80 #if IMAGEMAGICK
81 MagickInfo *mi;
82 ff.output = psiconv_gen_image;
83 for (mi = GetMagickInfo(NULL); mi ; mi = mi->next) {
84 if (mi->encoder) {
85 ff.name = strdup(mi->tag);
86 ff.description = strdup(mi->description);
87 psiconv_list_add(fileformat_list,&ff);
88 }
89 }
90 #endif
91 }
92

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