2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: testcgm.c /main/6 1996/06/11 16:10:02 cde-hal $ */
24 /* test module to try the CGM =->pixmap library */
26 #include <X11/Intrinsic.h>
31 #include "GraphicsP.h"
33 main(int argc, char **argv)
41 Dimension ret_width = 0, ret_height = 0;
43 int ret_number, pageNo;
45 Pixmap myPixmap = NULL;
50 _DtGrContext gr_context ;
52 if (!(display = XOpenDisplay(NULL))) {
53 fprintf(stderr, "couldn't open X display\n");
56 scr_num = DefaultScreen(display);
57 win = XCreateSimpleWindow(display, RootWindow(display, scr_num), 0, 0,
59 BlackPixel(display, scr_num),
60 WhitePixel(display, scr_num));
61 XSetStandardProperties(display, win, "VCGM", "VCGM", NULL, NULL, 0,
63 XMapWindow(display, win);
64 /* find out what we actually got */
65 XGetWindowAttributes(display, win, &wa);
67 /* make a reasonable GC */
68 mask = GCForeground | GCBackground;
69 myStruct.foreground = BlackPixel(display, scr_num);
70 myStruct.background = WhitePixel(display, scr_num);
71 myGC = XCreateGC(display, win, mask, &myStruct);
72 /* check on the filename */
73 fileName = (argc > 1) ? argv[1] : "test.cgm";
75 if ((argc < 3) || !sscanf(argv[2], " %d", &pageNo)) pageNo = 1;
77 /* first register our converter */
78 _DtGrRegisterConverter("CGM", processCGM, NULL, NULL, NULL);
81 /* set up our stream */
82 stream.type = _DtGrFILE ;
83 stream.source.file.filename = fileName ;
84 stream.source.file.fileptr = fopen(stream.source.file.filename, "r") ;
86 gr_context.image_type = NULL;
87 gr_context.context = NULL;
89 /* get the pixmap we want */
90 status = _DtGrLoad (&stream, NULL,
91 ScreenOfDisplay(display, scr_num),
95 BlackPixelOfScreen(ScreenOfDisplay(display, scr_num)),
96 WhitePixelOfScreen(ScreenOfDisplay(display, scr_num)),
107 /* exit if didn't get a Pixmap */
108 if ((status != _DtGrSUCCESS) || !myPixmap) {
109 fprintf(stderr, "no Pixmap returned!\n");
112 fprintf(stderr, "got Pixmap, width = %d, height = %d\n", ret_width,
116 /* wait for some tty input before we copy the pixmap */
117 fprintf(stderr, "hit return to see Pixmap!");
119 /* display the Pixmap */
120 XCopyArea(display, myPixmap, win, myGC, 0, 0, ret_width, ret_height,
123 /* wait for some tty input before we terminate */
124 fprintf(stderr, "hit return to terminate!");