[comp.windows.interviews] patch for monochrome Suns

linton@marktwain.rad.sgi.com (Mark Linton) (04/19/91)

Below is the fix for monochrome Suns or anything bw system with whitepixel == 0.

*** /tmp/,RCSt1a07294	Wed Apr 17 17:11:39 1991
--- iv/src/lib/IV-X11/xworld.c	Wed Apr 17 17:11:16 1991
***************
*** 146,157 ****
  	set_shift(visual_->green_mask, green_, green_shift_);
  	set_shift(visual_->blue_mask, blue_, blue_shift_);
  	break;
-     case StaticGray:
- 	rgbtable_ = nil;
- 	white_ = (1 << visual_->bits_per_rgb) - 1;
- 	break;
      default:
  	rgbtable_ = new RGBTable(256);
      }
      ctable_ = new ColorTable(256);
      localmap_ = nil;
--- 146,154 ----
  	set_shift(visual_->green_mask, green_, green_shift_);
  	set_shift(visual_->blue_mask, blue_, blue_shift_);
  	break;
      default:
  	rgbtable_ = new RGBTable(256);
+ 	break;
      }
      ctable_ = new ColorTable(256);
      localmap_ = nil;
***************
*** 395,409 ****
  	xc.red = (unsigned short)rescale(r, red_, 0xffff);
  	xc.green = (unsigned short)rescale(g, green_, 0xffff);
  	xc.blue = (unsigned short)rescale(b, blue_, 0xffff);
- 	break;
-     case StaticGray:
- 	unsigned long gray = rescale(
- 	    (30 * red + 59 * green + 11 * blue) / 100, 0xffff, white_
- 	);
- 	xc.pixel = gray;
- 	xc.red = (unsigned short)rescale(gray, white_, 0xffff);
- 	xc.green = (unsigned short)rescale(gray, white_, 0xffff);
- 	xc.blue = (unsigned short)rescale(gray, white_, 0xffff);
  	break;
      default:
  	unsigned long rg = (red << 16) | green;
--- 392,397 ----

nishio@kuis.kyoto-u.ac.jp (Nishio `Cchwitz' Shuichi) (04/19/91)

Reference -> Regarding patch for monochrome Suns; linton@marktwain.rad.sgi.com (Mark Linton) adds:

> Below is the fix for monochrome Suns or anything bw system with whitepixel == 0.

Is it possible to have this work selectively looking whether the
X-server takes 0 for whitepixel or not?


--nishio

linton@marktwain.rad.sgi.com (Mark Linton) (04/20/91)

In article <NISHIO.91Apr19221705@mizar.kuis.kyoto-u.ac.jp>, nishio@kuis.kyoto-u.ac.jp (Nishio `Cchwitz' Shuichi) writes:
|> Reference -> Regarding patch for monochrome Suns; linton@marktwain.rad.sgi.com (Mark Linton) adds:
|> 
|> > Below is the fix for monochrome Suns or anything bw system with whitepixel == 0.
|> 
|> Is it possible to have this work selectively looking whether the
|> X-server takes 0 for whitepixel or not?

I don't understand the question.  The new code should work regardless
of pixel definitions.  The old code assumed StaticGray visuals were like TrueColor
visuals for gray scale; this is incorrect.

nishio@kuis.kyoto-u.ac.jp (Nishio `Cchwitz' Shuichi) (04/20/91)

In article <1991Apr20.000903.9403@odin.corp.sgi.com> linton@marktwain.rad.sgi.com (Mark Linton) writes:
   |> Is it possible to have this work selectively looking whether the
   |> X-server takes 0 for whitepixel or not?

   I don't understand the question.  The new code should work regardless
   of pixel definitions.  The old code assumed StaticGray visuals were like TrueColor
   visuals for gray scale; this is incorrect.

Yes, sorry. It worked fine. 
Thanks.

--nishio