Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!sgi!shinobu!odin!cashew.asd.sgi.com!kurt From: kurt@cashew.asd.sgi.com (Kurt Akeley) Newsgroups: comp.sys.sgi Subject: Re: Getting compor map colors. Keywords: getmcolor Message-ID: <1991Apr23.173017.20815@odin.corp.sgi.com> Date: 23 Apr 91 17:30:17 GMT References: <1991Apr22.153229.7358@cs.ruu.nl> Sender: news@odin.corp.sgi.com (Net News) Reply-To: kurt@cashew.asd.sgi.com (Kurt Akeley) Organization: sgi Lines: 75 In article <1991Apr22.153229.7358@cs.ruu.nl>, markov@cs.ruu.nl (Mark Overmars) writes: |> I have the following problem. I want to draw colormap images inside a RGB |> window. As a result I need to find out what the colors in the colormap are. To |> this end I thought I should use the routine |> |> getmcolor() |> |> Unfortunately, this routine only work when you are in colormap mode, not when |> you are in RGB mode. (Why?) Because the colormap is indexed as a function of your framebuffer configuration, and the required information is not available in an RGB window. Specifically, color index windows are either in single-map or multi-map mode. When in multi- map mode, they access the differently than when in single-map mode. It is cleaner and more correct to disallow color map access to RGB windows. |> So the question is, how do I do it. To make this |> precise: I have an RGB window open, and I want a routine my_color(col) that |> sets the current RGB color to the color in index col in the colormap. Simply open another window using the desired color index mode, and use it to interrogate the colormap contents. I have included an example program below. Note that it calls noport() before opening the color index window, so that this window does not appear on the screen. |> (I need this for making the forms in the FORMS library into RGB windows and |> still maintaining the current behaviour of the package.) |> |> Mark Overmars -- Kurt -------------------------------- cut here ---------------------------------- /* Open an RGB window to draw into, and a color index drawing context to */ /* allow interrogation of the color map */ #include #include #include main() { long ciid, rgbid; short r,g,b; register i; rgbid = winopen("rgb"); RGBmode(); gconfig(); noport(); ciid = winopen("ci"); winset(rgbid); cpack(0); clear(); sleep(2); winset(ciid); for (i=0; i<8; i++) { getmcolor(i,&r,&g,&b); printf("%2d: %2x %2x %2x\n",i,r,g,b); } winset(rgbid); cpack(0xffffff); clear(); sleep(2); winset(ciid); for (i=0; i<8; i++) { getmcolor(i,&r,&g,&b); printf("%2d: %2x %2x %2x\n",i,r,g,b); } }