gif-cgi patch

Ronald Florence ron at mlfarm.com
Mon Feb 11 02:54:06 AEST 1991


Some time ago I posted a gif -> cgi filter for SCO Xenix and Unix
systems to comp.sources.misc (volume 13).  Gif-cgi is the ansi
version; gif-cgi2 is a non-ansi version.  While fiddling around with
gif-cgi to look at some Magellan images, I realized that the color
mapping was fouled up, especially for use with a monochrome VGA
display.  The following patch helps.  Better color mapping in the SCO
Xenix monochrome VGA video driver would help even more, but that seems
to be a lost cause.

If you missed the original code, it is available from uunet or most
comp.sources.misc archives.


----------------------------[gif patch]----------------------------
*** gif.c.old	Sat Feb  9 20:26:53 1991
--- gif.c	Sun Feb 10 10:37:01 1991
***************
*** 19,26 ****
  #include <stdio.h>
  #include <signal.h>
  
- #define Rgb1000(c)	(short)((c) * 1000.0/255.0)
- 
  typedef unsigned char Uchar;
  short	cgidev, Ystep, Xmax;
  
--- 19,24 ----
***************
*** 234,250 ****
       Uchar *cm;
  {
    Uchar	*scan;
    int	i;
    short rgb[3], rgb_out[3];
  
    for (scan = cm, i = cmap; colors > 0; scan += 3, i++, colors--)
      {
!       rgb[0] = Rgb1000(*scan);
!       rgb[1] = Rgb1000(*(scan + 1));
!       rgb[2] = Rgb1000(*(scan + 2));
! #ifdef BROKEN_MONO_VGA
!       if (i > 0 && rgb[1] == 0) 
! 	rgb[1] = 200;
  #endif
        vs_color(cgidev, i, rgb, rgb_out);
      }
--- 232,250 ----
       Uchar *cm;
  {
    Uchar	*scan;
+   unsigned int color;
    int	i;
    short rgb[3], rgb_out[3];
  
    for (scan = cm, i = cmap; colors > 0; scan += 3, i++, colors--)
      {
! #ifndef BROKEN_MONO_VGA
!       rgb[0] = *scan << 2;
!       rgb[1] = *(scan + 1) << 2;
!       rgb[2] = *(scan + 2) << 2;
! #else
!       color = 77 * *scan + 150 * *(scan + 1) + 29 * *(scan +2);
!       rgb[0] = rgb[1] = rgb[2] = color >> 6;
  #endif
        vs_color(cgidev, i, rgb, rgb_out);
      }
----------------------------[eof patch]----------------------------
--

Ronald Florence			ron at mlfarm.com



More information about the Comp.unix.sysv386 mailing list