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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 34 Revision 44
28#endif 28#endif
29 29
30/* This is ridiculously simple using ImageMagick. Without it, it would 30/* This is ridiculously simple using ImageMagick. Without it, it would
31 be quite somewhat harder - it will be left for later on */ 31 be quite somewhat harder - it will be left for later on */
32 32
33static void gen_paint_data_section(FILE *of, psiconv_paint_data_section sec, 33static Image *get_paint_data_section(psiconv_paint_data_section sec)
34{
35 Image *image;
36 image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green,
37 sec->blue,NULL);
38 return image;
39}
40
41
42static int psiconv_gen_image_clipart(FILE *of, psiconv_clipart_f f,
34 const char *dest) 43 const char *dest)
44{
45#if IMAGEMAGICK
46 psiconv_clipart_section section;
47 MagickInfo *mi = GetMagickInfo(dest);
48 ImageInfo image_info;
49 Image *image = NULL;
50 Image *last_image = NULL;
51 Image *this_image;
52 int i;
53
54 if ((psiconv_list_length(f->sections) < 1) ||
55 ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin)))
56#endif
57 return -1;
58#if IMAGEMAGICK
59 for (i = 0; i < psiconv_list_length(f->sections); i++) {
60 section = psiconv_list_get(f->sections,i);
61 this_image = get_paint_data_section(section->picture);
62 if (! image) {
63 image = this_image;
64 last_image = image;
65 } else {
66 last_image->next=this_image;
67 this_image->previous=last_image;
68 this_image->scene=i;
69 last_image=this_image;
70 }
71 }
72
73 GetImageInfo(&image_info);
74 image_info.file = of;
75 strcpy(image->magick, dest);
76 image_info.adjoin=1;
77 WriteImage(&image_info,image);
78 return 0;
79#endif
80}
81
82static int psiconv_gen_image_mbm(FILE *of, psiconv_mbm_f f, const char *dest)
83{
84#if IMAGEMAGICK
85 psiconv_paint_data_section section;
86 MagickInfo *mi = GetMagickInfo(dest);
87 ImageInfo image_info;
88 Image *image = NULL;
89 Image *last_image = NULL;
90 Image *this_image;
91 int i;
92
93 if ((psiconv_list_length(f->sections) < 1) ||
94 ((psiconv_list_length(f->sections)) > 1 && ! (mi->adjoin)))
95#endif
96 return -1;
97#if IMAGEMAGICK
98 for (i = 0; i < psiconv_list_length(f->sections); i++) {
99 section = psiconv_list_get(f->sections,i);
100 this_image = get_paint_data_section(section);
101 if (! image) {
102 image = this_image;
103 last_image = image;
104 } else {
105 last_image->next=this_image;
106 this_image->previous=last_image;
107 this_image->scene=i;
108 last_image=this_image;
109 }
110 }
111
112 GetImageInfo(&image_info);
113 image_info.file = of;
114 strcpy(image->magick, dest);
115 image_info.adjoin=1;
116 WriteImage(&image_info,image);
117 return 0;
118#endif
119}
120
121static void psiconv_gen_image_sketch(FILE *of, psiconv_sketch_f f,
122 const char *dest)
35{ 123{
36#if IMAGEMAGICK 124#if IMAGEMAGICK
37 ImageInfo image_info; 125 ImageInfo image_info;
38 Image *image; 126 Image *image;
39 127
40 image = CreateImage(sec->xsize,sec->ysize,sec->red,sec->green, 128 image = get_paint_data_section(f->sketch_sec->picture);
41 sec->blue,NULL);
42 GetImageInfo(&image_info); 129 GetImageInfo(&image_info);
43 image_info.file = of; 130 image_info.file = of;
44 strcpy(image->magick, dest); 131 strcpy(image->magick, dest);
45 WriteImage(&image_info,image); 132 WriteImage(&image_info,image);
46#endif 133#endif
47} 134}
48 135
49static 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
58static 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
64static int psiconv_gen_image(FILE * of, const psiconv_file file, 136static int psiconv_gen_image(FILE * of, const psiconv_file file,
65 const char *dest) 137 const char *dest)
66{ 138{
67 if (file->type == psiconv_mbm_file) { 139 if (file->type == psiconv_mbm_file)
68 psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest); 140 return psiconv_gen_image_mbm(of,(psiconv_mbm_f) file->file,dest);
69 return 0; 141 if (file->type == psiconv_clipart_file)
142 return psiconv_gen_image_clipart(of,(psiconv_clipart_f) file->file,dest);
70 } else if (file->type == psiconv_sketch_file) { 143 else if (file->type == psiconv_sketch_file) {
71 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest); 144 psiconv_gen_image_sketch(of,(psiconv_sketch_f) file->file,dest);
72 return 0; 145 return 0;
73 } else 146 } else
74 return -1; 147 return -1;
75} 148}

Legend:
Removed from v.34  
changed lines
  Added in v.44

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