[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Absolutely silly question ...



>  And now, just imagine that you have an undefined number of of pixmap
>  (changing with time, for example) and you want each pixmap to have a
>  different background. How do you manage memory allocation ?
>  Do you have to create an array with the maximum number of GdkColor and
>  change each item of this array. Can't  you have only one GdkColor for each
>  creation of pixmap ?

If all your pixmaps have the same visual and colormap, which I assume
they do, you can share the same GC among them.  When you need a new
color, you have to allocate it in the colormap (BTW, GdkColorContext
makes this easy).  When you want to fill a new pixmap with that color,
just set your GC's foreground to that and use it.

>  And for the GdkGC, I see that if you have only one, and associate a new
>  color each time, all the pixmap will have its color change. So it seems you
>  need a different gc for each pixmap. My question is the same as above, do
>  you have to keep each gc in an array or is there another solution ? (for
>  instance gdk_gc_new ..... then gdk_gc_destroy, to free memory).

Once something has been painted in the pixmap, it will not change if
you make changes to the GC.  However, the colors may change if you
modify an existing color in the colormap (think of it as changing the
palette).

I suggest that you take a look at the Xlib programmer's manual; it
will make a lot of these things clear.

  Federico



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]