home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!network.ucsd.edu!ucsbcsl!ucsbuxa!6500msd
- From: 6500msd@ucsbuxa.ucsb.edu (Michael D'Errico)
- Newsgroups: comp.windows.x
- Subject: Re: Finding out the number of 'free' cells in the color map
- Keywords: color map, color cells
- Message-ID: <6747@ucsbcsl.ucsb.edu>
- Date: 18 Nov 92 01:08:25 GMT
- Article-I.D.: ucsbcsl.6747
- References: <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au> <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu>
- Sender: root@ucsbcsl.ucsb.edu
- Lines: 48
-
- In article <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
-
- |In article <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au>, s8923098@macnab.mqcs.mq.oz.au (Josef WIDJAJA) writes:
-
- |> I want to use XAllocColor many times to allocate color cells that can
- |> be shared by other applications. But I want to know in advance how
- |> many of these will be available. How can I do this ?
-
- |You can't. For one thing, it depends on exactly what colors you're
- |allocating, because you may match colors that are already allocated and
- |hence get an already-allocated cell instead of a new one. Even if you
- |rephrase it to ask "how many cells are unallocated", there is no simple
- |way to answer it; you have to try it and see. (Unless you want to
- |design and implement an extension, of course.)
-
- |> [code example]
-
- |> I want to know how many color cells are going to be available so that
- |> I can adjust the value of maxno, and prepare data[i]'s accordingly.
- |> More specifically, I want to make sure that result is always
- |> succesful(true).
-
- |Can't be done. Even if you did contrive somehow to find out how many
- |cells are free, other clients could allocate cells while you're
- |working. You'd have to grab the server to prevent this....
-
- I agree that there is no way (at least not yet) to query the number of unused
- color cells in a colormap. You could probably get around this with the
- following approach: use a loop that adjusts maxno until you successfully
- allocate the colormap. The following pseudo-code shows what I would try:
-
- maxno = desired_maxno;
- done = False;
-
- while (!done && maxno>=min_allowable_maxno) {
- if (try_to_allocate_maxno_colors)
- done = True;
- else {
- free_any_allocated_colors;
- maxno--;
- }
-
- if (!done)
- error;
-
-
- Michael D'Errico
- 6500msd@ucsbuxa.ucsb.edu
-