Re: [gtk-list] Re: what is the pixel value of the GdkColor ?



On Wed, May 26, 1999 at 05:33:21PM +0200, Stefan Ondrejicka wrote:
> On Wed, 26 May 1999, Sven LUTHER wrote:
> 
> Hi !
> 
> > > easy way, how to do it :
> > > 
> > > 	color = colormap->colors[pixel];
> > > 
> > > But, I hope that, there should be some function for it.
> > 
> > In my case, i am writting a binding for ocaml, an ml style language and what
> > you just described is quite un-nice. a :
> > 
> > Gdkcolor gdk_colormap_get_pixel_color (GdkColormap colormap, gunit32 pixel)
> > 
> > would be very nice,
> 
> I mean too, but there isn't such function (or am I blind ?).

Hello, ...

I have been playing a bit more with colormaps this weekend, and have this
problem:

i modified the scribble-simple.c example to do the folowing :

in toplevel :

GdkGC *gc;

in configure_event :

  GdkColormap *cmap;
  GdkColor col;

  ... pixmap_new stuff ...
  
  gc = gdk_gc_new (widget->window);
  cmap = gdk_window_get_colormap(widget->window);
  col.red = 0; col.green = 0; col.blue = 65535;
  gdk_colormap_alloc_color (cmap, &col, TRUE, TRUE);
  cmap->colors[col.pixel]=col;
  gdk_gc_set_foreground (gc, &cmap->colors[col.pixel]);
  
  ... draw_rectangle stuff ...
  
in draw_brsuh, i use gc instead of widget->style.black_gc to draw.

But i see no change, it still is a black pixel and not a blue one.

so i added

  gdk_colormap_change (cmap, col.pixel+1);
  
before gdk_gc_set_foreground, and i get the following error :

Gdk-ERROR **: BadAccess (attempt to access private resource denied)
  serial 107 error_code 10 request_code 89 minor_code 0

Then i remove again the gdk_colormap_change call, and the square is drawn in
blue.

I did this at home on my 8bpp Pseudocolor Planar display under linux/ppc and
with libgtk1.2.3 (debian system).

Here at work, i have a Solaris Ultra 1 box, and libgtk1.2.0 and i got only no
square at all the second time i run this.

Where is the problem.

Also i noticed this color and colormap and gc stuff is very complicated, shoudl
there not be a much simpler API for it ?

Friendly,

Sven LUTHER





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