/*********************************************************************** * * * xwpick.c - main routine for xwpick * * * * Author: Evgeni Chernyaev (chernaev@mx.ihep.su) * * * * Copyright (C) 1993, 1994 by Evgeni Chernyaev. * * * * Permission to use, copy, modify, and distribute this software and * * its documentation for non-commercial purpose is hereby granted * * without fee, provided that the above copyright notice appear in all * * copies and that both the copyright notice and this permission * * notice appear in supporting documentation. * * * * This software is provided "as is" without express or implied * * warranty. * * * ***********************************************************************/ #include #include #include #include #include char ProgName[] = "xwpick"; char ProgVers[] = "Version 2.20 Rev: 20/09/94 - by Evgeni Chernyaev"; char FileName[80]; #ifdef __STDC__ #define ARGS(alist) alist #else #define ARGS(alist) () #endif #ifdef __VMS #define VMS_STYLE 1 #else #ifdef VMS #define VMS_STYLE 1 #else #define VMS_STYLE 0 #endif #endif #define MAX_ARG 10 #define TIMEOUT 30 #define MIN_WIDTH 8 #define MIN_HEIGHT 8 typedef unsigned char byte; typedef void (*vfp)(); static Display *dsp; static XImage *image; static FILE *out; /* G L O B A L P R E D E F I N I T I O N S */ int ImgCheckDisplay ARGS((Display *)); void ImgGetRectangle ARGS((Display *,Window *,int *,int *,int *,int *)); void ImgGetCurrentWindow ARGS((Display *,Window *,int *,int *,int *,int *)); int ImgGetWindowById ARGS((Display *,Window,int *,int *,int *,int *)); int ImgPause ARGS((Display *,int)); XImage *ImgPickImage ARGS((Display *,int,int,int,int)); void ImgPickPalette ARGS((Display *,Window,int *,int *,int *,int *)); void ImgFinalFlash ARGS((Display *,int,int,int,int)); void ImgFreeImage ARGS((XImage *)); long PS_LZWencode ARGS((int,int,int,int,byte *,byte *,byte *,byte *,vfp,vfp)); long PSencode ARGS((int,int,int,byte *,byte *,byte *,byte *,vfp,vfp)); long GIFencode ARGS((int,int,int,byte *,byte *,byte *,byte *,vfp,vfp)); long PCXencode ARGS((int,int,int,byte *,byte *,byte *,byte *,vfp,vfp)); long PPMencode ARGS((int,int,int,byte *,byte *,byte *,byte *,vfp,vfp)); long PICTencode ARGS((int,int,int,byte *,byte *,byte *,byte *,vfp,vfp)); /* L O C A L F U N C T I O N S */ static void get_scline(y, width, scline) int y, width; byte scline[]; { int i; for (i=0; i]\n",ProgName,ProgName); fprintf(stderr,"%s: possible options:\n",ProgName); fprintf(stderr," -local select window under the mouse pointer\n"); fprintf(stderr," -window id select window by id\n"); fprintf(stderr," -reverse transfer image to reverse colors\n"); fprintf(stderr," -gray transfer image to grayscale\n"); fprintf(stderr," -pause wait the bar click\n"); fprintf(stderr," -format frm set output format\n"); fprintf(stderr, "%s: possible file names: *.ps,*.eps,*.epsi,*.gif,*.pcx,*.pict,*.ppm\n", ProgName); exit(1); } static void quit(message) char *message; { fprintf(stderr,"%s: %s\n",ProgName,message); XBell(dsp, 0); XBell(dsp, 0); XBell(dsp, 0); XCloseDisplay(dsp); fclose(out); exit(1); } static int vms_parser(argc,argv,strng) int argc; char *argv[], strng[]; { int i, j, k, n; char c; if (argc == 1) return 1; for (strng[0]='\0', k=i=1; i