On Wed, 28 Nov 2001, Ba la wrote:
> Hi Mark,
> I need to change the colors dynamically, so I
> have to use XAllocColorCells(), that is what mentioned
> in man pages, is it possible to change dynamically the
> colors, when we use XAllocColor().
You cannot change the colors associated with a pixel
in TrueColor modes. That's why TrueColor colormaps are
called read-only maps. If you need to do palette effects
and have the colors change without redrawing the scene,
that can only be done on read-write maps like PseudoColor
or DirectColor.
>
> I setted my display in 8bpp mode, so that example is
> working, but when my netscape is open, I con't run my
> XAllocColorCells example, it is giving error as
>
> Bad Access(int parameter out of range for access)
> mager opcode (X_StoreColor)failed
XStoreColors failed because the XAllocColorCells
failed in the first place and you can't store colors
in cells that you haven't allocated. They failed to
allocate for you because Netscape already allocated
most of them. You are trying to allocate colors on
the default map and doing so will only succeed if other
apps haven't already allocated them. You can create
your own colormap and use that instead but you will
get the "color flashing" that happens when the colormaps
are swapped when your window comes into focus. Basically,
programming in PseudoColor mode is problematic in general
on PC hardware because PC hardware only has a single hardware
palette that has to be shared by all.
>
> it is giving the error like this, when I close my
> netscape it is working fine, when I start my example
> after that I start netscape, then no problem I cam
> quit my example and start again it will work.
>
> why the Bad Access error from XStoreColor() is
> comming even in 8bpp mode also(when the netscape is
> open), is it not enough space is not available for
> XStoreColor() to store the values, or we need to
> validate the parameters to XStoreColors(), so that it
> won't give int parameter out of range error, if it is
> so, how to validate the parameters to XAllocColors().
>
You need to think about what you really need to do
color-wise. In TrueColor you can use as many colors as
you want but you cannot change the color associated with
a pixel value. In PseudoColor you can only allocate as
many cells as are free in the colormap. You can create
a new colormap with all the cells free but then you get
"color flashing" as the X-server swaps maps in and out.
Mark.
_______________________________________________
Xpert mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/xpert