Re: GdkColor and GdkGC question



Andrei Zmievski <andrei ispi net> writes: 
> This obviously won't work on Windows.. Or does Windows port
> automatically fill in the red/green/blue values?

Right, well 1.2 does not officially work on Windows. ;-) With 2.0
Windows is officially supported and we have gdk_colormap_query_color()
that's portable... let me see what it does on win32...

void
gdk_colormap_query_color (GdkColormap *colormap,
                          gulong       pixel,
                          GdkColor    *result)
{
  GdkVisual *visual;

  g_return_if_fail (GDK_IS_COLORMAP (colormap));
  
  visual = gdk_colormap_get_visual (colormap);

  switch (visual->type) {
  case GDK_VISUAL_DIRECT_COLOR:
  case GDK_VISUAL_TRUE_COLOR:
    result->red = 65535. * (double)((pixel & visual->red_mask) >>
  visual->red_shift) / ((1 << visual->red_prec) - 1);
    result->green = 65535. * (double)((pixel & visual->green_mask) >>
  visual->green_shift) / ((1 << visual->green_prec) - 1);
    result->blue = 65535. * (double)((pixel & visual->blue_mask) >>
  visual->blue_shift) / ((1 << visual->blue_prec) - 1);
    break;
  case GDK_VISUAL_STATIC_GRAY:
  case GDK_VISUAL_GRAYSCALE:
    result->red = result->green = result->blue = 65535. *
  (double)pixel/((1<<visual->depth) - 1);
    break;
  case GDK_VISUAL_STATIC_COLOR:
    g_assert_not_reached ();
    break;
  case GDK_VISUAL_PSEUDO_COLOR:
    result->red = colormap->colors[pixel].red;
    result->green = colormap->colors[pixel].green;
    result->blue = colormap->colors[pixel].blue;
    break;
  default:
    g_assert_not_reached ();
    break;
  }
}

So, I have no idea if that works with 1.2, but maybe it does.

> Is there a #define that I can use to conditionally compile this function
> in under X-windows?
> 

Maybe G_OS_WIN32 or something like that? I'm sure there's
something. If nothing else you can check in your app's configure
script.

Havoc




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