⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkrgb.c

📁 gtk是linux一款强大的夸平台的图形化开发工具
💻 C
📖 第 1 页 / 共 5 页
字号:
{  gdk_rgb_min_colors = min_colors;}/* Return a "score" based on the following criteria (in hex):   x000 is the quality - 1 is 1bpp, 2 is 4bpp,                         4 is 8bpp,			 7 is 15bpp truecolor, 8 is 16bpp truecolor,			 9 is 24bpp truecolor.   0x00 is the speed - 1 is the normal case,                       2 means faster than normal   00x0 gets a point for being the system visual   000x gets a point for being pseudocolor   A caveat: in the 8bpp modes, being the system visual seems to be   quite important. Thus, all of the 8bpp modes should be ranked at   the same speed.*/static guint32gdk_rgb_score_visual (GdkVisual *visual){  guint32 quality, speed, sys, pseudo;  static const gchar* visual_names[] =  {    "static gray",    "grayscale",    "static color",    "pseudo color",    "true color",    "direct color",  };  quality = 0;  speed = 1;  sys = 0;  if (visual->type == GDK_VISUAL_TRUE_COLOR ||      visual->type == GDK_VISUAL_DIRECT_COLOR)    {      if (visual->depth == 24)	{	  quality = 9;	  /* Should test for MSB visual here, and set speed if so. */	}      else if (visual->depth == 16)	quality = 8;      else if (visual->depth == 15)	quality = 7;      else if (visual->depth == 8)	quality = 4;    }  else if (visual->type == GDK_VISUAL_PSEUDO_COLOR ||	   visual->type == GDK_VISUAL_STATIC_COLOR)    {      if (visual->depth == 8)	quality = 4;      else if (visual->depth == 4)	quality = 2;      else if (visual->depth == 1)	quality = 1;    }  else if (visual->type == GDK_VISUAL_STATIC_GRAY#ifdef ENABLE_GRAYSCALE	   || visual->type == GDK_VISUAL_GRAYSCALE#endif	   )    {      if (visual->depth == 8)	quality = 4;      else if (visual->depth == 4)	quality = 2;      else if (visual->depth == 1)	quality = 1;    }  if (quality == 0)    return 0;  sys = (visual == gdk_visual_get_system ());  pseudo = (visual->type == GDK_VISUAL_PSEUDO_COLOR || visual->type == GDK_VISUAL_TRUE_COLOR);  if (gdk_rgb_verbose)    g_print ("Visual 0x%x, type = %s, depth = %d, %x:%x:%x%s; score=%x\n",	     (gint)(((GdkVisualPrivate *)visual)->xvisual->visualid),	     visual_names[visual->type],	     visual->depth,	     visual->red_mask,	     visual->green_mask,	     visual->blue_mask,	     sys ? " (system)" : "",	     (quality << 12) | (speed << 8) | (sys << 4) | pseudo);  return (quality << 12) | (speed << 8) | (sys << 4) | pseudo;}static voidgdk_rgb_choose_visual (void){  GList *visuals, *tmp_list;  guint32 score, best_score;  GdkVisual *visual, *best_visual;  visuals = gdk_list_visuals ();  tmp_list = visuals;  best_visual = tmp_list->data;  best_score = gdk_rgb_score_visual (best_visual);  tmp_list = tmp_list->next;  while (tmp_list)    {      visual = tmp_list->data;      score = gdk_rgb_score_visual (visual);      if (score > best_score)	{	  best_score = score;	  best_visual = visual;	}      tmp_list = tmp_list->next;    }  g_list_free (visuals);  image_info->visual = best_visual;}static void gdk_rgb_select_conv (GdkImage *image);static voidgdk_rgb_set_gray_cmap (GdkColormap *cmap){  gint i;  GdkColor color;  gint status;  gulong pixels[256];  gint r, g, b, gray;  for (i = 0; i < 256; i++)    {      color.pixel = i;      color.red = i * 257;      color.green = i * 257;      color.blue = i * 257;      status = gdk_color_alloc (cmap, &color);      pixels[i] = color.pixel;#ifdef VERBOSE      g_print ("allocating pixel %d, %x %x %x, result %d\n",	       color.pixel, color.red, color.green, color.blue, status);#endif    }  /* Now, we make fake colorcubes - we ultimately just use the pseudocolor     methods. */  colorcube = g_new (guchar, 4096);  for (i = 0; i < 4096; i++)    {      r = (i >> 4) & 0xf0;      r = r | r >> 4;      g = i & 0xf0;      g = g | g >> 4;      b = (i << 4 & 0xf0);      b = b | b >> 4;      gray = (g + ((r + b) >> 1)) >> 1;      colorcube[i] = pixels[gray];    }}voidgdk_rgb_init (void){  gint i;  static const gint byte_order[1] = { 1 };  /* check endian sanity */#if G_BYTE_ORDER == G_BIG_ENDIAN  if (((char *)byte_order)[0] == 1)    g_error ("gdk_rgb_init: compiled for big endian, but this is a little endian machine.\n\n");#else  if (((char *)byte_order)[0] != 1)    g_error ("gdk_rgb_init: compiled for little endian, but this is a big endian machine.\n\n");#endif  if (image_info == NULL)    {      image_info = g_new0 (GdkRgbInfo, 1);      image_info->visual = NULL;      image_info->cmap = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -