home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / displytl / xvimage.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  7.8 KB  |  249 lines

  1. #ifndef _xvHeader_
  2. #define _xvHeader_
  3. /*
  4.  *  xv.h  -  header file for xv, but you probably guessed as much
  5.  */
  6.  
  7. /*
  8.  * Copyright 1989, 1990 by the University of Pennsylvania
  9.  *
  10.  * Permission to use, copy, and distribute for non-commercial purposes,
  11.  * is hereby granted without fee, providing that the above copyright
  12.  * notice appear in all copies and that both the copyright notice and this
  13.  * permission notice appear in supporting documentation.
  14.  *
  15.  * The software may be modified for your own purposes, but modified versions
  16.  * may not be distributed.
  17.  *
  18.  * This software is provided "as is" without any express or implied warranty.
  19.  */
  20. /* $Header $ */
  21. /* $Log $ */
  22. #define REVDATE   "Rev: 11/29/90  (Patchlevel 3)"
  23.  
  24. #ifdef SVR4             /* SysV release 4 uses dirent */
  25. #ifndef sgi             /* but Silicon Graphics doesn't */
  26. #define DIRENT
  27. #endif
  28. #endif
  29.  
  30.  
  31. /* include files */
  32. #include <stdio.h>
  33. #include <math.h>
  34. #include <ctype.h>
  35. #include <string.h>
  36. extern int   errno;             /* this SHOULD be in errno.h */
  37. extern char *sys_errlist[];     /* this SHOULD be in errno.h */
  38.  
  39. #ifndef __convexc__             /* Convex doesn't have <memory.h> */
  40. #include <memory.h>             /* for 'memset()' prototype */
  41. #endif
  42.  
  43. /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have <malloc.h> */
  44. #if !defined(ibm032) && !defined(__convexc__) && \
  45.     !(defined(vax) && !defined(ultrix))
  46. #if defined(hp300) || defined(hp800)
  47. #include <sys/malloc.h>                /* it's in 'sys' on HPs*/
  48. #else
  49. #include <malloc.h>
  50. #endif
  51. #endif
  52.  
  53.  
  54. #if defined(NEED_MEMROUTINES)
  55. #define memcpy(d,s,l) bcopy(s,d,l)
  56. #endif
  57.  
  58.  
  59. #include <X11/Xos.h>
  60. #include <X11/Xlib.h>
  61. #include <X11/Xutil.h>
  62. #include <X11/cursorfont.h>
  63. #include <X11/keysym.h>
  64.  
  65.  
  66. #if defined(NEEDSTIME) || defined(NEEDSDIR)
  67. #include <sys/types.h>    /* only include <sys/types.h> once */
  68. #endif
  69.  
  70. #ifdef NEEDSTIME
  71. #ifndef sgi              /* silicon graphics doesn't have timeb.h */
  72. #include <sys/timeb.h>
  73. #endif
  74. #include <signal.h>
  75. #if defined(sco) && !defined(NOTIMER)
  76. #include <sys/itimer.h>
  77. #endif
  78. #ifndef  sigmask
  79. #define  sigmask(m)      (1 << ((m)-1))
  80. #endif
  81. #endif
  82.  
  83. #ifdef NEEDSDIR
  84. #ifdef sco
  85. #include <sys/ndir.h>
  86. #define lstat stat
  87. #else
  88. #ifndef ATT
  89. #include <sys/dir.h>
  90. #endif  /* ATT */
  91. #endif  /* sco */
  92. #include <sys/param.h>
  93. #include <sys/stat.h>
  94. #ifdef DIRENT
  95. #include <dirent.h>
  96. #endif
  97. #endif
  98.  
  99. #ifdef NEEDSVARARGS
  100. #include <varargs.h>
  101. #endif
  102.  
  103. #ifdef i386
  104. #define MAXPATHLEN    500
  105. #endif
  106.  
  107. #define F_GREYSCALE 1
  108. #define MAXNAMES 1024   /* max # of files (more than this?  Get REAL!) */
  109.  
  110. /* MACROS */
  111. /* RANGE forces a to be in the range b..c (inclusive) */
  112. #define RANGE(a,b,c) { if (a<b) a=b;  if (a>c) a=c; }
  113.  
  114. /* MONO returns total intensity of r,g,b components */
  115. #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5)  /*.33R+ .5G+ .17B*/
  116.  
  117. /* types of 24-to-8 conversion */
  118. #define CONV24_FAST 0
  119. #define CONV24_SLOW 1
  120. #define CONV24_BEST 2
  121.  
  122. /* X stuff */
  123. Display       *theDisp;
  124. int           theScreen;
  125. unsigned int  ncells, dispWIDE, dispHIGH, dispDEEP;
  126. Colormap      theCmap, LocalCmap;
  127. Window        rootW, mainW;
  128. GC            theGC;
  129. unsigned long black, white, fg, bg, infofg, infobg;
  130. Visual        *theVisual;
  131.  
  132. typedef unsigned char byte;
  133.  
  134. /* global vars used by LOAD routines */
  135. byte          *pic;                   /* ptr to loaded picture */
  136. unsigned int   pWIDE,pHIGH;           /* size of 'pic' */
  137. byte           r[256],g[256],b[256];  /* colormap */
  138. char          *cmd;                   /* program name for printf's */
  139. int            DEBUG;                 /* print debugging info */
  140. int            mono;                  /* true if displaying grayscale */
  141.  
  142.  
  143. /* more global variables, used by xv and xvmisc */
  144. byte          *cpic;         /* cropped version of pic */
  145. unsigned int  cWIDE, cHIGH,  /* size of cropped region */
  146.                     cXOFF, cYOFF;  /* offset of region from 0,0 of pic */
  147.  
  148. byte          *epic;         /* expanded version of cpic */
  149.                                    /* points to pic when at 1:1 expansion */
  150.                                    /* this is converted to 'theImage' */
  151. unsigned int  eWIDE, eHIGH;  /* size of epic */
  152. unsigned int  normFact;      /* factor to shrink picture by for 'norm' */
  153.  
  154. byte           rorg[256],gorg[256],borg[256];  /* ORIGINAL colormap */
  155. byte           gamcr[256];   /* gamma correction curve */
  156. byte           fsgamcr[256]; /* gamma correction curve (for FS dither) */
  157. char           *namelist[MAXNAMES];  /* list of file names from argv */
  158. int            numnames, curname;
  159. char           formatStr[80];
  160.  
  161. int           verbose;
  162. unsigned long freecols[256]; /* list of pixel values to free */
  163. int           nfcols;        /* number of colors to free */
  164. unsigned long cols[256];     /* maps pic pixel values to X pixel vals */
  165. int           fc2pcol[256];  /* maps freecols into pic pixel values */
  166. int           numcols;       /* # of desired colors in picture */
  167. int           ncols;         /* max # of (different) colors to alloc */
  168.  
  169. char          str[128];      /* dummy string used for error messages */
  170.  
  171. int           expand,        /* expansion amount */
  172.                     bwidth,        /* border width of created windows */
  173.                     noglob,        /* force to only use colors it alloced */
  174.                     revvideo,      /* reverse video */
  175.                     perfect,       /* perfect color.  install own colormap */
  176.                     fixedaspect,   /* fixed aspect ratio */
  177.                     conv24,        /* use slow 24to8 algorithm */
  178.                     ninstall,      /* true if using icccm-complaint WM
  179.                       (a WM that will does install CMaps */
  180.                     useroot,       /* true if we should draw in rootW */
  181.                     noqcheck,      /* true if we should NOT do QuickCheck */
  182.                     rwcolor,       /* true if we should use R/W color cells */
  183.                     rwthistime,    /* true if we DID use R/W color cells */
  184.                     brokeFreeCols, /* true if server has broken XFreeColors */
  185.                     fish,          /* turn on annoying fish */
  186.                     fishrunning;   /* true if fish are in operation */
  187.  
  188. float         defaspect,     /* default aspect ratio to use */
  189.                     normaspect;    /* normal aspect ratio of this picture */
  190.  
  191. int           crx1, cry1,    /* dimensions of cropping rectangle */
  192.                     crx2, cry2;
  193.  
  194. /* function declarations for externally-callable functions */
  195.  
  196. #ifdef __STDC__ 
  197.  
  198. /*************************** XVMISC.C ***************************/
  199. Window CreateWindow(char *, char *, unsigned int, unsigned int, 
  200.             unsigned long, unsigned long);
  201. void SortColormap(void);
  202. void AllocColors(void);
  203. void DoMonoAndRV(void);
  204. void FatalError(char *);
  205.  
  206. /*************************** XV24TO8.C **************************/
  207. int  Conv24to8(byte *, int, int, int);
  208. void InitFSDTables(void);
  209.  
  210. /**************************** XVGIF.C ***************************/
  211. int LoadGIF(char *, int);
  212.  
  213. /**************************** XVTIFF.C ***************************/
  214. int LoadTIFF(char *, int);
  215. /* int WriteTIFF(FILE *, byte *, int, int, char *); */
  216.  
  217. /**************************** XVJPEG.C ***************************/
  218. int LoadJFIF(char *, int);
  219.  
  220. #else     /* using non-ANSI cc.  Function defs, but no params */
  221.  
  222. /*************************** XVMISC.C ***************************/
  223. Window CreateWindow();
  224. XImage*        Resize(byte* origData, int origWidth, int origHeight,
  225.                int newWidth, int newHeight);
  226. void SortColormap();
  227. void AllocColors();
  228. void DoMonoAndRV();
  229. void FatalError();
  230.  
  231.  
  232. /*************************** XV24TO8.C **************************/
  233. int  Conv24to8();
  234. void InitFSDTables();
  235.  
  236. /**************************** XVGIF.C ***************************/
  237. int LoadGIF();
  238.  
  239.  
  240. /**************************** XVTIFF.C ***************************/
  241. int LoadTIFF();
  242. /*  WriteTIFF(); */
  243.  
  244. /**************************** XVJPEG.C ***************************/
  245. int LoadJFIF();
  246.  
  247. #endif
  248. #endif
  249.