File:  [CSRG BSD Unix] / 43BSDReno / contrib / isode-beta / others / quipu / uips / pod / photo.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:56 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43reno
BSD 4.3reno

#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/photo.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif

/*
 * $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/photo.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
 */

/*
 * $Log: photo.c,v $
 * Revision 1.1.1.1  2018/04/24 16:12:56  root
 * BSD 4.3reno
 *
 * Revision 7.0  90/06/12  13:15:50  mrose
 * *** empty log message ***
 * 
 * Revision 1.5  90/04/26  10:21:15  emsrdsm
 * *** empty log message ***
 * 
 * Revision 1.4  90/04/25  13:47:26  emsrdsm
 * i) lint'ed
 * 
 * Revision 1.3  90/04/20  10:28:20  emsrdsm
 * (i) fixed form bug
 * 
 * Revision 1.2  90/04/18  18:48:19  emsrdsm
 * i) added logging
 * 
 * Revision 1.1  90/04/10  16:44:23  emsrdsm
 * Initial revision
 * 
 */

#include "quipu/photo.h"
#include "pod.h"

extern Widget toplevel;
extern Widget PhotoWindow;

extern GC XCreateGC();
GC gc;
char photo_name[1024];
Pixmap photo_pixmap = 0;
Display *dpy;
Screen *scr;
int winX, winY, winW, winH;
extern int NUMLINES,PIC_LINESIZE;
extern unsigned position;
unsigned long XorVal;

static int passno = 1;
static int x, y;
int px, py, maxx;

extern int two_passes;

/*ARGSUSED*/
photo_start (name)
char *name;
{
  x = y = 0;
  if (passno == 1)
    maxx = 0, two_passes = 1;
  return 0;
}

photo_end (name)
char *name;
{
  if (passno == 1) {
    passno = 2;
    px = x = maxx;
    py = --y;
  
    if (photo_pixmap) {
      XFreePixmap(XtDisplay(toplevel), photo_pixmap);
      photo_pixmap = 0;
    }

    kill_photo();
    make_photo_widget();

    dpy = XtDisplay(toplevel);
    scr = DefaultScreenOfDisplay(dpy);
    
    winW = x;
    winH = y;

    photo_pixmap = XCreatePixmap(dpy, XtWindow(PhotoWindow),
				 x, y, DefaultDepthOfScreen(scr));
    gc = XCreateGC(dpy, photo_pixmap, 0, NULL);

    XSetFunction(dpy, gc, GXclear);
    
    XSetForeground(dpy, gc, WhitePixelOfScreen(scr));
    XSetBackground(dpy, gc, BlackPixelOfScreen(scr));
    
    XFillRectangle(dpy, photo_pixmap, gc, 0, 0, winW,winH);

    XSetFunction(dpy, gc, GXcopy);

    XSetForeground(dpy, gc, BlackPixelOfScreen(scr));
    XSetBackground(dpy, gc, WhitePixelOfScreen(scr));

    XFillRectangle(dpy, photo_pixmap, gc, 0, 0, winW,winH);

    XSetForeground(dpy, gc, WhitePixelOfScreen(scr));
    XSetBackground(dpy, gc, BlackPixelOfScreen(scr));
    
    XorVal = WhitePixelOfScreen(scr) ^ BlackPixelOfScreen(scr);
    
    return 0;
  }
  if (name && *name) (void) strcpy(photo_name, name);
  passno = 1;
  x = y = maxx = 0;
  return 0;
}

/*ARGSUSED*/
photo_line_end (line)
bit_string * line;
{
  /* the end of a line has been reached */
  /* A bit string is stored in line->dbuf_top */
  
  if (passno == 1 && x > maxx)
    maxx = x;
  x = 0, y++;
  
  return 0;
}

photo_black (length)
int length;
{
  if (passno == 1) {
    x += length;
    return 0;
  }
  /* draw a black line of 'length' pixels */
  
  return 0;
}

photo_white (length)
int length;
{
  if (passno == 1) {
    x += length;
    return 0;
  }
  
  /* draw a white line of 'length' pixels */
  XDrawLine (dpy, photo_pixmap, gc, 
	     position, NUMLINES, length+position-1, NUMLINES);
  
  return 0;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.