static VALUE rg_query_color(VALUE self, VALUE pixel) { GdkColor color; gdk_colormap_query_color(_SELF(self), NUM2ULONG(pixel), &color); return GDKCOLOR2RVAL(&color); }
static void psdrawpixmap (GtkPlotPC *pc, GdkPixmap *pixmap, GdkBitmap *mask, gint xsrc, gint ysrc, gint xdest, gint ydest, gint width, gint height, gdouble scale_x, gdouble scale_y) { FILE *psout = GTK_PLOT_PS(pc)->psfile; GdkColormap *colormap; colormap = gdk_colormap_get_system (); fprintf(psout, "gsave\n"); if(pixmap){ GdkImage *image; gint x, y; image = gdk_image_get(pixmap, xsrc, ysrc, width, height); if(mask) gtk_plot_pc_clip_mask(pc, xdest, ydest, mask); fprintf(psout, "%d %g translate\n", xdest, ydest + height * scale_y); fprintf(psout, "%g %g scale\n",width * scale_x, height * scale_y); fprintf(psout, "%d %d 8 [%d 0 0 %d 0 %d]\n",width, height, width, height, height); fprintf(psout, "/scanline %d 3 mul string def\n", width); fprintf(psout, "{ currentfile scanline readhexstring pop } false 3\n"); fprintf(psout, "colorimage\n"); for(y = 0; y < height; y++){ for(x = 0; x < width; x++){ GdkColor color; gchar string[7]; color.pixel = gdk_image_get_pixel(image, x, y); gdk_colormap_query_color(colormap, color.pixel, &color); color_to_hex(color, string); fprintf(psout,"%s",string); if(fmod(x + 1, 13) == 0) fprintf(psout, "\n"); } fprintf(psout,"\n"); } gdk_image_destroy(image); if(mask) gtk_plot_pc_clip_mask(pc, xdest, ydest, NULL); } fprintf(psout, "grestore\n"); }
GdkColor query_color (GtkWidget * win, GdkColor c) { GdkColor real_color; GdkColormap *cmap; cmap = gtk_widget_get_colormap (GTK_WIDGET (win)); if (cmap && GDK_IS_COLORMAP (cmap)) { gdk_colormap_query_color (cmap, c.pixel, &real_color); return real_color; } else { return c; } }
static void cl_draw_corner (GdkWindow *window, GtkWidget *widget, GtkStyle *style, int x, int y, int width, int height, CLRectangle *r, CLCornerSide corner) { GdkColor *color; GdkColor aacolor; /* anti-aliasing color */ GdkGCValues values; GdkColor tmp; GdkColor *bgcolor; int x1; int y1; if (r->corners[corner] == CL_CORNER_NONE) return; color = cl_get_gradient_corner_color (r, corner); gdk_gc_get_values (r->bordergc, &values); if (color == NULL) { tmp = values.foreground; gdk_colormap_query_color (gtk_widget_get_colormap(widget), values.foreground.pixel, &tmp); color = &tmp; } bgcolor = get_parent_bgcolor(widget); if (bgcolor == NULL) { bgcolor = color; } blend (style->colormap, bgcolor, color, &aacolor, 70); if (r->corners[corner] == CL_CORNER_ROUND) { x1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_BOTTOMLEFT) ? x+1 : x+width - 2; y1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_TOPRIGHT) ? y+1 : y+height - 2; gdk_gc_set_foreground (r->bordergc, color); gdk_draw_point (window, r->bordergc, x1, y1); gdk_gc_set_foreground (r->bordergc, &aacolor); x1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_BOTTOMLEFT) ? x+1 : x+width-2; y1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_TOPRIGHT) ? y : y+height-1; gdk_draw_point (window, r->bordergc, x1, y1); x1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_BOTTOMLEFT) ? x : x+width-1; y1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_TOPRIGHT) ? y+1 : y+height-2; gdk_draw_point (window, r->bordergc, x1, y1); } else if (r->corners[corner] == CL_CORNER_NARROW) { x1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_BOTTOMLEFT) ? x : x+width-1; y1 = (corner == CL_CORNER_TOPLEFT || corner == CL_CORNER_TOPRIGHT) ? y : y+height-1; gdk_gc_set_foreground (r->bordergc, &aacolor); gdk_draw_point (window, r->bordergc, x1, y1); } gdk_gc_set_foreground (r->bordergc, &values.foreground); }
void vik_gc_get_fg_color ( GdkGC *gc, GdkColor *dest ) { static GdkGCValues values; gdk_gc_get_values ( gc, &values ); gdk_colormap_query_color ( gdk_colormap_get_system(), values.foreground.pixel, dest ); }