Line data Source code
1 : /* Copyright (C) 2000-2012 by George Williams */
2 : /*
3 : * Redistribution and use in source and binary forms, with or without
4 : * modification, are permitted provided that the following conditions are met:
5 :
6 : * Redistributions of source code must retain the above copyright notice, this
7 : * list of conditions and the following disclaimer.
8 :
9 : * Redistributions in binary form must reproduce the above copyright notice,
10 : * this list of conditions and the following disclaimer in the documentation
11 : * and/or other materials provided with the distribution.
12 :
13 : * The name of the author may not be used to endorse or promote products
14 : * derived from this software without specific prior written permission.
15 :
16 : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 : * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 : * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 : * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 : * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 : * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 : * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 : * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 : * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 : * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 : */
27 : #include "gdraw.h"
28 : #include <string.h>
29 :
30 0 : int GImageWriteEps(GImage *gi, char *filename) {
31 0 : struct _GImage *base = gi->list_len==0?gi->u.image:gi->u.images[0];
32 : GPrinterAttrs pattrs;
33 : GWindow epsfile;
34 :
35 0 : memset(&pattrs,'\0',sizeof(pattrs));
36 0 : pattrs.mask |= pam_pagesize;
37 0 : pattrs.width = base->width/72; pattrs.height = base->height/72;
38 0 : pattrs.mask |= pam_margins;
39 0 : pattrs.lmargin = pattrs.rmargin = pattrs.tmargin = pattrs.bmargin = 0;
40 0 : pattrs.mask |= pam_scale;
41 0 : pattrs.scale = 1.0;
42 0 : pattrs.mask |= pam_res;
43 0 : pattrs.res = 72;
44 0 : pattrs.mask |= pam_color;
45 0 : pattrs.do_color = true;
46 0 : if (( base->clut==NULL && base->image_type==it_mono ) ||
47 0 : (base->clut!=NULL && GImageGreyClut(base->clut)) )
48 0 : pattrs.do_color = false;
49 0 : pattrs.mask |= pam_queue;
50 0 : pattrs.donot_queue = true;
51 0 : pattrs.mask |= pam_eps;
52 0 : pattrs.eps = true;
53 0 : pattrs.mask |= pam_filename;
54 0 : pattrs.file_name = filename;
55 :
56 0 : epsfile = GPrinterStartJob(NULL,NULL,&pattrs);
57 0 : if ( epsfile==NULL )
58 0 : return( false );
59 0 : GDrawDrawImage(epsfile,gi,NULL,0,0);
60 0 : return( GPrinterEndJob(epsfile,false));
61 : }
|