Path: utzoo!news-server.csri.toronto.edu!rutgers!bellcore!uunet!mcsun!corton!inria!seti!fantasia!mamou From: mamou@bdblues.altair.fr (Jean Claude Mamou) Newsgroups: comp.windows.x Subject: read/write colorcells problem Message-ID: <1991Mar13.154106@fantasia.altair.fr> Date: 13 Mar 91 14:41:06 GMT Sender: news@seti.inria.fr Reply-To: mamou@bdblues.altair.fr Organization: GIP Altair - BP 105 - 78153 Le Chesnay Cedex Lines: 76 Hello, I have a problem to allocate read/write colorcells in a colormap. If I create a new virtual colormap with XCopyColrormapAndFree after a failure of XAllocColorCells, one of the extra allocation requests returns a bad pixel value (e.g. 256) that is out of range of the colormap. I give below an example of code producing that problem. Does someone know about that, and is it a known way of doing such a thing ? Thanks. ----------------------------------------------------------------------------- Jean-Claude Mamou | tel : +33 (1) 39.63.58.20 GIP ALTAIR | fax : +33 (1) 39.63.58.90 Domaine de Voluceau | email : mamou@bdblues.altair.fr BP 105, 78153 Le Chesnay Cedex, FRANCE | ----------------------------------------------------------------------------- #include #include #include main (argc,argv) int argc; char *argv[]; { int i,j,numcols, alloccols,theScreen; Colormap cmap, theCmap,LocalCmap; XColor defs[256]; char * display; Display *theDisp; unsigned char r[256],g[256],b[256]; display = NULL; LocalCmap =0; if ((theDisp = XOpenDisplay(display)) == NULL) { printf(stderr, "%s: Can't open display\n",argv[0]); exit(1);} theScreen = DefaultScreen(theDisp); theCmap = DefaultColormap(theDisp, theScreen); cmap = theCmap; XSynchronize(theDisp, True); /* Allocate one pixel */ defs[0].pixel = 2; XAllocColor(theDisp, cmap, &defs[0]); alloccols = 0; numcols = 256; for (i=0; i