[comp.windows.x] Visible pixel boundaries in xmag

josh@suntan.viewlogic.com (Josh Marantz) (05/30/91)

I find the program xmag really useful, but my eyes got tired trying to
count pixels.  So I made a quick hack to the program that draws lines
between the blown-up pixels so you can count them.

It uses XOR mode to show contrast, and we all know how perilous that
can be, but the behavior seems acceptable after minimal testing on
X11R4/Sparc I/Sun 4.1.1.

I don't know whether this could go into the R5 distribution, but I
guess we'd need a new command line option (right now it always behaves
this way), and a man page update.

Here's the (short) context diff:

-Josh

*** /u/olivaw/X11R4/clients/xmag/xmag.c	Sun Dec 10 17:24:10 1989
--- xmag.c	Wed May 29 20:46:15 1991
***************
*** 42,47 ****
--- 42,48 ----
  Window w;				/* enlargement window */
  Window root;				/* root window of screen */
  GC fillGC = (GC) NULL;			/* for drawing enlargement */
+ GC invGC  = (GC) NULL;             	/* for drawing source region outline */
  Bool do_grab = False;			/* grab server */
  char *pix_font = NULL;			/* for displaying pixel value */
  
***************
*** 545,551 ****
      int lastx, lasty;
      unsigned int mask;
      Bool done;
-     static GC invGC = (GC) NULL;	/* for drawing source region outline */
      static Cursor invCursor;
  
      if (!invGC) {			/* make it the first time */
--- 546,551 ----
***************
*** 864,869 ****
--- 864,893 ----
  
  	r_y += magnification;		/* advance to next scanline */
      }					/* end for */
+ 
+     /*
+      * Draw lines between the rows and columns so we can count the pixels!
+      * Use XOR mode to hopefully get some sort of contrast.
+      *
+      * -5/29/91, Joshua Marantz, Viewlogic Systems, Inc., josh@viewlogic.com
+      */
+     for (row = e_row; row <= maxrow; row++) {
+         int y = row * magnification;
+         XDrawLine (dpy, w, invGC,
+                    initialx, y,
+                    initialx + (1 + maxcolumn) * magnification, y);
+     } /* for */
+ 
+     {
+         int initial_y = e_row * magnification;
+ 
+         for (column = e_column; column <= maxcolumn; column++) {
+             int x = column * magnification;
+             XDrawLine (dpy, w, invGC,
+                        x, initial_y,
+                        x, initial_y + (1 + maxrow) *  magnification);
+         } /* for */
+     }
  
      XFlush (dpy);
      return;
-- 
Joshua Marantz
Viewlogic Systems, Inc.
josh@viewlogic.com
        Why not pass the time by playing a little solitaire?