Update of /cvsroot/netrek/client/cow
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20304

Modified Files:
	system.mk.in x11window.c 
Added Files:
	camera.c 
Log Message:
tactical camera, based on Imlib2

--- NEW FILE: camera.c ---
/* prototype camera support */

#include <stdio.h>
#include <X11/Xlib.h>
#include <Imlib2.h>
#include "defs.h"

/* internal context */
static Display *disp = NULL;
static Visual *vis = NULL;
static Screen *scr = NULL;
static Colormap cm;
static Window rw, tw;
static int rx, ry;
static unsigned int rdx, rdy;

/* set the display used by the camera */
void camera_set_display(Display *arg_disp)
{
  int depth;

  disp = arg_disp;
  scr = ScreenOfDisplay(disp, DefaultScreen(disp));
  vis = DefaultVisual(disp, XScreenNumberOfScreen(scr));
  depth = DefaultDepth(disp, XScreenNumberOfScreen(scr));
  cm = DefaultColormap(disp, XScreenNumberOfScreen(scr));
  rw = RootWindow(disp, XScreenNumberOfScreen(scr));
  
  imlib_context_set_display(disp);
  imlib_context_set_visual(vis);
  imlib_context_set_colormap(cm);
  imlib_context_set_color_modifier(NULL);
  imlib_context_set_operation(IMLIB_OP_COPY);
}

/* set the window used by the camera */
void camera_set_window(Window arg_window, int arg_width, int arg_height)
{
  tw = arg_window;
  rx = 0;
  ry = 0;
  rdx = TWINSIDE;	/* restrict to tactical */
  rdy = TWINSIDE;
  imlib_context_set_drawable(tw);
}

void camera_snap()
{
  Imlib_Image image;

  image = imlib_create_image_from_drawable(rw, rx, ry, rdx, rdy, 0);
  imlib_context_set_image(image);
  imlib_image_attach_data_value("quality", NULL, 15, NULL);
  imlib_save_image("cow-camera-frame.png");
  imlib_free_image_and_decache();
}

Index: x11window.c
===================================================================
RCS file: /cvsroot/netrek/client/cow/x11window.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- x11window.c	16 May 2006 06:25:25 -0000	1.7
+++ x11window.c	16 May 2006 12:59:38 -0000	1.8
@@ -4,6 +4,9 @@
  * Kevin P. Smith  6/11/89 Much modified by Jerry Frain and Joe Young
  *
  * $Log$
+ * Revision 1.8  2006/05/16 12:59:38  quozl
+ * tactical camera, based on Imlib2
+ *
  * Revision 1.7  2006/05/16 06:25:25  quozl
  * some compilation fixes
  *
@@ -456,6 +459,7 @@
   /* tmp */
   /* XSynchronize(W_Display, True); */
   /* XSetErrorHandler(_myerror); */
+  camera_set_display(W_Display);
 
   W_Root = DefaultRootWindow(W_Display);
 
@@ -1006,6 +1010,9 @@
 			    CWBorderPixel,
 			    &attrs),
 		      WIN_GRAPH);
+  if (strcmp(name, "netrek") == 0) {
+    camera_set_window(newwin->window, width, height);
+  }
   /* top window */
   sz_hints = XAllocSizeHints();
   if (strcmp(name, "netrek") == 0 || strcmp(name, "wait") == 0 ||

Index: system.mk.in
===================================================================
RCS file: /cvsroot/netrek/client/cow/system.mk.in,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- system.mk.in	31 Jan 2006 18:34:06 -0000	1.7
+++ system.mk.in	16 May 2006 12:59:38 -0000	1.8
@@ -72,7 +72,7 @@
 	          netstat.o netstatopt.o spopt.o dashboard.o dashboard3.o \
 	          short.o distress.o senddist.o defwin.o tools.o sound.o\
 		  docwin.o cflags.o beeplite.o feature.o\
-		  string_util.o local.o censor.o cowmain.o
+		  string_util.o local.o censor.o cowmain.o camera.o
 
 RSRC 		= check.c colors.c data.c death.c defaults.c dmessage.c\
 	          enter.c findslot.c getname.c getship.c helpwin.c inform.c\
@@ -83,7 +83,7 @@
                   lagmeter.c netstat.c netstatopt.c spopt.c dashboard.c dashboard3.c \
 		  short.c distress.c senddist.c defwin.c tools.c sound.c\
 		  docwin.c cflags.c beeplite.c feature.c reserved.c\
-		  string_util.c local.c censor.c cowmain.c
+		  string_util.c local.c censor.c cowmain.c camera.c
 
 
 INCLUDES 	= struct.h packets.h defs.h copyright.h bitmaps.h data.h\
@@ -113,7 +113,7 @@
 
 netrek: $(RSAOBJ) $(PMAKE) null $(ROBJ) $(MAINOBJ) $(INPUTOBJ) $(X11OBJ) $(WIN32OBJ)  $(RANDOMOBJ) cflags.c randomize
 	$(CC) $(LFLAGS) -o netrek `./randomize $(ROBJ) $(RSAOBJ) $(INPUTOBJ) \
-	$(MAINOBJ) $(X11OBJ) $(WIN32OBJ) $(RANDOMOBJ)` $(LIBRARIES)
+	$(MAINOBJ) $(X11OBJ) $(WIN32OBJ) $(RANDOMOBJ)` $(LIBRARIES) -lImlib2
 
 netrek.shared: done.libcow $(MAINOBJ) $(COWAPI)
 	$(CC) $(LFLAGS) $(MAINOBJ) -L. -lcow $(LIBS) -o netrek.shared