📄 gdkrgb.c
字号:
image_info->color_pixels = NULL; image_info->gray_pixels = NULL; image_info->reserved_pixels = NULL; image_info->nred_shades = 6; image_info->ngreen_shades = 6; image_info->nblue_shades = 4; image_info->ngray_shades = 24; image_info->nreserved = 0; image_info->bpp = 0; image_info->cmap_alloced = FALSE; image_info->gamma = 1.0; image_info->stage_buf = NULL; image_info->own_gc = NULL; gdk_rgb_choose_visual (); if ((image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR || image_info->visual->type == GDK_VISUAL_STATIC_COLOR) && image_info->visual->depth < 8 && image_info->visual->depth >= 3) { image_info->cmap = gdk_colormap_get_system (); gdk_rgb_colorcube_222 (); } else if (image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR) { if (gdk_rgb_install_cmap || image_info->visual != gdk_visual_get_system ()) { image_info->cmap = gdk_colormap_new (image_info->visual, FALSE); image_info->cmap_alloced = TRUE; } if (!gdk_rgb_do_colormaps ()) { image_info->cmap = gdk_colormap_new (image_info->visual, FALSE); image_info->cmap_alloced = TRUE; gdk_rgb_do_colormaps (); } if (gdk_rgb_verbose) g_print ("color cube: %d x %d x %d\n", image_info->nred_shades, image_info->ngreen_shades, image_info->nblue_shades); if (!image_info->cmap_alloced) image_info->cmap = gdk_colormap_get_system (); }#ifdef ENABLE_GRAYSCALE else if (image_info->visual->type == GDK_VISUAL_GRAYSCALE) { image_info->cmap = gdk_colormap_new (image_info->visual, FALSE); gdk_rgb_set_gray_cmap (image_info->cmap); image_info->cmap_alloced = TRUE; }#endif else { /* Always install colormap in direct color. */ if (image_info->visual->type != GDK_VISUAL_DIRECT_COLOR && image_info->visual == gdk_visual_get_system ()) image_info->cmap = gdk_colormap_get_system (); else { image_info->cmap = gdk_colormap_new (image_info->visual, FALSE); image_info->cmap_alloced = TRUE; } } image_info->bitmap = (image_info->visual->depth == 1); for (i = 0; i < N_IMAGES; i++) if (image_info->bitmap) /* Use malloc() instead of g_malloc since X will free() this mem */ static_image[i] = gdk_image_new_bitmap (image_info->visual, (gpointer) malloc (IMAGE_WIDTH * IMAGE_HEIGHT >> 3), IMAGE_WIDTH, IMAGE_HEIGHT); else static_image[i] = gdk_image_new (GDK_IMAGE_FASTEST, image_info->visual, IMAGE_WIDTH, IMAGE_HEIGHT); image_info->bpp = static_image[0]->bpp; gdk_rgb_select_conv (static_image[0]); }}/* convert an rgb value into an X pixel code */gulonggdk_rgb_xpixel_from_rgb (guint32 rgb){ gulong pixel = 0; if (image_info->bitmap) { return ((rgb & 0xff0000) >> 16) + ((rgb & 0xff00) >> 7) + (rgb & 0xff) > 510; } else if (image_info->visual->type == GDK_VISUAL_PSEUDO_COLOR) pixel = colorcube[((rgb & 0xf00000) >> 12) | ((rgb & 0xf000) >> 8) | ((rgb & 0xf0) >> 4)]; else if (image_info->visual->depth < 8 && image_info->visual->type == GDK_VISUAL_STATIC_COLOR) { pixel = colorcube_d[((rgb & 0x800000) >> 17) | ((rgb & 0x8000) >> 12) | ((rgb & 0x80) >> 7)]; } else if (image_info->visual->type == GDK_VISUAL_TRUE_COLOR || image_info->visual->type == GDK_VISUAL_DIRECT_COLOR) {#ifdef VERBOSE g_print ("shift, prec: r %d %d g %d %d b %d %d\n", image_info->visual->red_shift, image_info->visual->red_prec, image_info->visual->green_shift, image_info->visual->green_prec, image_info->visual->blue_shift, image_info->visual->blue_prec);#endif pixel = (((((rgb & 0xff0000) >> 16) >> (8 - image_info->visual->red_prec)) << image_info->visual->red_shift) + ((((rgb & 0xff00) >> 8) >> (8 - image_info->visual->green_prec)) << image_info->visual->green_shift) + (((rgb & 0xff) >> (8 - image_info->visual->blue_prec)) << image_info->visual->blue_shift)); } else if (image_info->visual->type == GDK_VISUAL_STATIC_GRAY || image_info->visual->type == GDK_VISUAL_GRAYSCALE) { int gray = ((rgb & 0xff0000) >> 16) + ((rgb & 0xff00) >> 7) + (rgb & 0xff); return gray >> (10 - image_info->visual->depth); } return pixel;}voidgdk_rgb_gc_set_foreground (GdkGC *gc, guint32 rgb){ GdkColor color; color.pixel = gdk_rgb_xpixel_from_rgb (rgb); gdk_gc_set_foreground (gc, &color);}voidgdk_rgb_gc_set_background (GdkGC *gc, guint32 rgb){ GdkColor color; color.pixel = gdk_rgb_xpixel_from_rgb (rgb); gdk_gc_set_background (gc, &color);}#if G_BYTE_ORDER == G_LITTLE_ENDIAN#define HAIRY_CONVERT_8#endif#ifdef HAIRY_CONVERT_8static voidgdk_rgb_convert_8 (GdkImage *image, gint x0, gint y0, gint width, gint height, guchar *buf, int rowstride, gint x_align, gint y_align, GdkRgbCmap *cmap){ int x, y; gint bpl; guchar *obuf, *obptr; guchar *bptr, *bp2; gint r, g, b; bptr = buf; bpl = image->bpl; obuf = ((guchar *)image->mem) + y0 * bpl + x0; for (y = 0; y < height; y++) { bp2 = bptr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -