printf ("Chose visual 0x%x, image bpp=%d, %s first\n", (int)image_info->x_visual_info->visual->visualid, bpp, byte_order == LSB_FIRST ? "lsb" : "msb");
PRINTF ("Chose visual 0x%x, image bpp=%d, %s first\n", (int)image_info->x_visual_info->visual->visualid, bpp, byte_order == LSB_FIRST ? "lsb" : "msb");
xlib_rgb_select_conv (XImage *image, ByteOrder byte_order){  int depth, byterev;  int vtype; /* visual type */  int bpp; /* bits per pixel - from the visual */  uint32 red_mask, green_mask, blue_mask;  XlibRgbConvFunc conv, conv_d;  XlibRgbConvFunc conv_32, conv_32_d;  XlibRgbConvFunc conv_gray, conv_gray_d;  XlibRgbConvFunc conv_indexed, conv_indexed_d;  Bool mask_rgb, mask_bgr;  depth = image_info->x_visual_info->depth;  bpp = image->bits_per_pixel;  if (xlib_rgb_verbose)    printf ("Chose visual 0x%x, image bpp=%d, %s first\n",	    (int)image_info->x_visual_info->visual->visualid,	    bpp, byte_order == LSB_FIRST ? "lsb" : "msb");#if G_BYTE_ORDER == G_BIG_ENDIAN  byterev = (byte_order == LSB_FIRST);#else  byterev = (byte_order == MSB_FIRST);#endif  vtype = image_info->x_visual_info->class;  if (vtype == DirectColor)    vtype = TrueColor;  red_mask = image_info->x_visual_info->red_mask;  green_mask = image_info->x_visual_info->green_mask;  blue_mask = image_info->x_visual_info->blue_mask;  mask_rgb = red_mask == 0xff0000 && green_mask == 0xff00 && blue_mask == 0xff;  mask_bgr = red_mask == 0xff && green_mask == 0xff00 && blue_mask == 0xff0000;  conv = NULL;  conv_d = NULL;  conv_32 = xlib_rgb_convert_32_generic;  conv_32_d = xlib_rgb_convert_32_generic_d;  conv_gray = xlib_rgb_convert_gray_generic;  conv_gray_d = xlib_rgb_convert_gray_generic_d;  conv_indexed = xlib_rgb_convert_indexed_generic;  conv_indexed_d = xlib_rgb_convert_indexed_generic_d;  image_info->dith_default = FALSE;  if (image_info->bitmap)    conv = xlib_rgb_convert_1;  else if (bpp == 16 && depth == 16 && !byterev &&      red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f)    {      conv = xlib_rgb_convert_565;      conv_d = xlib_rgb_convert_565_d;      conv_gray = xlib_rgb_convert_565_gray;      xlib_rgb_preprocess_dm_565 ();    }  else if (bpp == 16 && depth == 16 &&	   vtype == TrueColor&& byterev &&      red_mask == 0xf800 && green_mask == 0x7e0 && blue_mask == 0x1f)    conv = xlib_rgb_convert_565_br;  else if (bpp == 16 && depth == 15 &&	   vtype == TrueColor && !byterev &&      red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f)    conv = xlib_rgb_convert_555;  else if (bpp == 16 && depth == 15 &&	   vtype == TrueColor && byterev &&      red_mask == 0x7c00 && green_mask == 0x3e0 && blue_mask == 0x1f)    conv = xlib_rgb_convert_555_br;  /* I'm not 100% sure about the 24bpp tests - but testing will show*/  else if (bpp == 24 && depth == 24 && vtype == TrueColor &&	   ((mask_rgb && byte_order == LSB_FIRST) ||	    (mask_bgr && byte_order == MSB_FIRST)))    conv = xlib_rgb_convert_888_lsb;  else if (bpp == 24 && depth == 24 && vtype == TrueColor &&	   ((mask_rgb && byte_order == MSB_FIRST) ||	    (mask_bgr && byte_order == LSB_FIRST)))    conv = xlib_rgb_convert_888_msb;#if G_BYTE_ORDER == G_BIG_ENDIAN  else if (bpp == 32 && depth == 24 && vtype == TrueColor &&	   (mask_rgb && byte_order == LSB_FIRST))    conv = xlib_rgb_convert_0888_br;  else if (bpp == 32 && depth == 24 && vtype == TrueColor &&	   (mask_rgb && byte_order == MSB_FIRST))    conv = xlib_rgb_convert_0888;  else if (bpp == 32 && depth == 24 && vtype == TrueColor &&	   (mask_bgr && byte_order == MSB_FIRST))    conv = xlib_rgb_convert_8880_br;#else  else if (bpp == 32 && depth == 24 && vtype == TrueColor &&	   (mask_rgb && byte_order == MSB_FIRST))    conv = xlib_rgb_convert_0888_br;  else if (bpp == 32 && (depth == 32 || depth == 24) && vtype == TrueColor &&	   (mask_rgb && byte_order == LSB_FIRST))    conv = xlib_rgb_convert_0888;  else if (bpp == 32 && depth == 24 && vtype == TrueColor &&	   (mask_bgr && byte_order == LSB_FIRST))    conv = xlib_rgb_convert_8880_br;#endif  else if (vtype == TrueColor && byte_order == LSB_FIRST)    {      conv = xlib_rgb_convert_truecolor_lsb;      conv_d = xlib_rgb_convert_truecolor_lsb_d;    }  else if (vtype == TrueColor && byte_order == MSB_FIRST)    {      conv = xlib_rgb_convert_truecolor_msb;      conv_d = xlib_rgb_convert_truecolor_msb_d;    }  else if (bpp == 8 && depth == 8 && (vtype == PseudoColor#ifdef ENABLE_GRAYSCALE				      || vtype == GrayScale#endif				      ))    {      image_info->dith_default = TRUE;      conv = xlib_rgb_convert_8;      if (vtype != GrayScale)	{	  if (image_info->nred_shades == 6 &&	      image_info->ngreen_shades == 6 &&	      image_info->nblue_shades == 6)	    conv_d = xlib_rgb_convert_8_d666;	  else	    conv_d = xlib_rgb_convert_8_d;	}      conv_indexed = xlib_rgb_convert_8_indexed;      conv_gray = xlib_rgb_convert_gray_cmap;    }  else if (bpp == 8 && depth == 8 && (vtype == StaticGray#ifdef not_ENABLE_GRAYSCALE				      || vtype == GrayScale#endif				      ))    {      conv = xlib_rgb_convert_gray8;      conv_gray = xlib_rgb_convert_gray8_gray;    }  else if (bpp == 8 && depth < 8 && depth >= 2 &&	   (vtype == StaticGray	    || vtype == GrayScale))    {      conv = xlib_rgb_convert_gray4;      conv_d = xlib_rgb_convert_gray4_d;    }  else if (bpp == 8 && depth < 8 && depth >= 3)    {      conv = xlib_rgb_convert_4;    }  else if (bpp == 4 && depth <= 4 && depth >= 2 &&	   (vtype == StaticGray	    || vtype == GrayScale))    {      conv = xlib_rgb_convert_gray4_pack;      conv_d = xlib_rgb_convert_gray4_d_pack;    }  if (conv_d == NULL)    conv_d = conv;  image_info->conv = conv;  image_info->conv_d = conv_d;  image_info->conv_32 = conv_32;  image_info->conv_32_d = conv_32_d;  image_info->conv_gray = conv_gray;  image_info->conv_gray_d = conv_gray_d;  image_info->conv_indexed = conv_indexed;  image_info->conv_indexed_d = conv_indexed_d;}