2 * webcam.c - fetch data from webcam and display
14 #include <X11/Xutil.h>
16 #include <X11/extensions/shape.h>
18 // #include "images/ivac-logo.xpm"
19 // #include "images/ivac-logo.h"
20 #include "images/example_orig.xbm"
24 #define XBM_REAL_WIDTH 512
25 #define XBM_HEIGHT 256
26 // #define ivac_logo pixel_data
27 #define ivac_logo example_bits
29 /* global variables */
31 Window ivac_win,icon_win;
36 void open_window(char *name,char *ivac_mask) {
39 int screen,width,height;
41 XSizeHints my_size_hints;
42 XClassHint my_class_hints;
49 screen=DefaultScreen(display);
50 root_win=DefaultRootWindow(display);
52 width=XBM_WIDTH; /* DisplayWidth(display,screen)/5; */
53 height=XBM_HEIGHT; /* DisplayHeight(diplay,screen)/5; */
54 my_size_hints.flags=USSize;
55 my_size_hints.width=width;
56 my_size_hints.height=height;
58 my_class_hints.res_name=name;
59 my_class_hints.res_class=name;
61 black=BlackPixel(display,screen);
62 white=WhitePixel(display,screen);
65 ivac_win=XCreateSimpleWindow(display,root_win,0,0,
69 icon_win=XCreateSimpleWindow(display,ivac_win,0,0,
74 /* set wm and class hints */
75 XSetWMNormalHints(display,ivac_win,&my_size_hints);
76 XSetClassHint(display,ivac_win,&my_class_hints);
78 /* select event input - what are we listening to? */
79 XSelectInput(display,ivac_win,
80 ExposureMask | ButtonPressMask | ButtonReleaseMask |
82 XSelectInput(display,icon_win,
83 ExposureMask | ButtonPressMask | ButtonReleaseMask |
86 /* set names for windows */
87 XStoreName(display,ivac_win,name);
88 XSetIconName(display,ivac_win,name);
90 /* graphics context values */
91 my_gc_val.foreground=black;
92 my_gc_val.background=white;
93 my_gc_val.graphics_exposures=False;
95 /* set graphics context */
96 my_gc=XCreateGC(display,ivac_win,
97 GCForeground | GCBackground | GCGraphicsExposures,
100 /* create pixmap mask and shape windows */
101 pixmap_mask=XCreateBitmapFromData(display,ivac_win,ivac_mask,
102 XBM_WIDTH,XBM_HEIGHT);
103 XShapeCombineMask(display,ivac_win,ShapeBounding,0,0,pixmap_mask,ShapeSet);
104 XShapeCombineMask(display,icon_win,ShapeBounding,0,0,pixmap_mask,ShapeSet);
106 /* define and set wmhints */
107 my_wm_hints.initial_state=WithdrawnState;
108 my_wm_hints.flags=StateHint;
109 my_wm_hints.icon_window=icon_win;
110 my_wm_hints.icon_x=my_size_hints.x;
111 my_wm_hints.icon_y=my_size_hints.y;
112 my_wm_hints.window_group=ivac_win;
114 StateHint | IconWindowHint | IconPositionHint | WindowGroupHint;
115 // XSetWMHints(display,ivac_win,&my_wm_hints);
117 /* finaly ... map that stuff ;) */
118 XMapWindow(display,ivac_win);
124 int main(int argc,char **argv) {
126 /* local variables */
130 /* opening display */
131 display=XOpenDisplay(NULL); /* connect on local display :0 */
133 printf("cannot connect to xserver!\n");
137 /* minirgb initialization */
138 if (minirgb_init(display)) {
139 printf("minirgb initialization failed!\n");
143 open_window(argv[0],(char *)ivac_logo);
144 minirgb_new(&rgb1,XBM_WIDTH,XBM_HEIGHT);
145 minirgb_new(&rgb2,XBM_WIDTH,XBM_HEIGHT);
146 minirgb_copy(&rgb2,&rgb1,0,0,XBM_WIDTH,XBM_HEIGHT,0,0);
148 /* to be continued ... here is a test! */
151 printf("blaaaa, schmaeee\n");
152 XCloseDisplay(display);