Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Enumerations | Functions | Variables
xlibrgb.h File Reference
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Intrinsic.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _XlibRgbCmap
struct  XlibRgbArgs

Defines

#define FUNCPROTO   15
#define NS_XLIBRGB_API(type)   type
#define XXLIBRGB_DEFAULT_HANDLE   ("xxlib-default")

Typedefs

typedef int int32
typedef unsigned short uint16
typedef short int16
typedef struct _XlibRgbCmap
typedef struct _XlibRgbHandle

Enumerations

enum  XlibRgbDither { XLIB_RGB_DITHER_NONE, XLIB_RGB_DITHER_NORMAL, XLIB_RGB_DITHER_MAX }

Functions

 xxlib_rgb_create_handle (Display *display, Screen *screen, XlibRgbArgs *args)
 xxlib_rgb_destroy_handle (XlibRgbHandle *handle)
 xxlib_rgb_xpixel_from_rgb (XlibRgbHandle *handle, uint32 rgb)
 xxlib_rgb_gc_set_foreground (XlibRgbHandle *handle, GC gc, uint32 rgb)
 xxlib_rgb_gc_set_background (XlibRgbHandle *handle, GC gc, uint32 rgb)
 xxlib_draw_rgb_image (XlibRgbHandle *handle, Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride)
 xxlib_draw_rgb_image_dithalign (XlibRgbHandle *handle, Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride, int xdith, int ydith)
 xxlib_draw_rgb_32_image (XlibRgbHandle *handle, Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride)
 xxlib_draw_gray_image (XlibRgbHandle *handle, Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride)
 xxlib_rgb_cmap_new (XlibRgbHandle *handle, uint32 *colors, int n_colors)
 xxlib_rgb_cmap_free (XlibRgbHandle *handle, XlibRgbCmap *cmap)
 xxlib_draw_indexed_image (XlibRgbHandle *handle, Drawable drawable, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *buf, int rowstride, XlibRgbCmap *cmap)
 xxlib_draw_xprint_scaled_rgb_image (XlibRgbHandle *handle, Drawable drawable, long paper_resolution, long image_resolution, GC gc, int x, int y, int width, int height, XlibRgbDither dith, unsigned char *rgb_buf, int rowstride)
 xxlib_rgb_ditherable (XlibRgbHandle *handle)
 xxlib_rgb_set_verbose (XlibRgbHandle *handle, Bool verbose)
 xxlib_rgb_set_min_colors (XlibRgbHandle *handle, int min_colors)
 xxlib_rgb_get_cmap (XlibRgbHandle *handle)
 xxlib_rgb_get_visual (XlibRgbHandle *handle)
 xxlib_rgb_get_visual_info (XlibRgbHandle *handle)
 xxlib_rgb_get_depth (XlibRgbHandle *handle)
 xxlib_rgb_get_display (XlibRgbHandle *handle)
 xxlib_rgb_get_screen (XlibRgbHandle *handle)
 xxlib_get_prec_from_mask (unsigned long)
 xxlib_get_shift_from_mask (unsigned long)
 xxlib_register_handle (const char *name, XlibRgbHandle *handle)
 xxlib_deregister_handle (const char *name)
 xxlib_find_handle (const char *name)

Variables

_XFUNCPROTOBEGIN typedef
unsigned int 
uint32

Class Documentation

struct _XlibRgbCmap

Definition at line 110 of file xlibrgb.h.

Class Members
unsigned int colors
unsigned char lut
struct XlibRgbArgs

Definition at line 123 of file xlibrgb.h.

Collaboration diagram for XlibRgbArgs:
Class Members
int disallow_image_tiling
int disallow_mit_shmem
const char * handle_name
int install_colormap
int pseudogray
int verbose
XVisualInfo xtemplate
long xtemplate_mask

Define Documentation

#define FUNCPROTO   15

Definition at line 71 of file xlibrgb.h.

Definition at line 104 of file xlibrgb.h.

#define XXLIBRGB_DEFAULT_HANDLE   ("xxlib-default")

Definition at line 266 of file xlibrgb.h.


Typedef Documentation

typedef struct _XlibRgbCmap

Definition at line 107 of file xlibrgb.h.

typedef struct _XlibRgbHandle

Definition at line 108 of file xlibrgb.h.

typedef short int16

Definition at line 102 of file xlibrgb.h.

typedef int int32

Definition at line 100 of file xlibrgb.h.

typedef unsigned short uint16

Definition at line 101 of file xlibrgb.h.


Enumeration Type Documentation

Enumerator:
XLIB_RGB_DITHER_NONE 
XLIB_RGB_DITHER_NORMAL 
XLIB_RGB_DITHER_MAX 

Definition at line 116 of file xlibrgb.h.


Function Documentation

xxlib_deregister_handle ( const char *  name)

Definition at line 4095 of file xlibrgb.c.

{
  RegisteredHandle *entry;
  if ((entry = xxlib_find_registered_handle(name)) != NULL)
  {
    free((void *)entry->name);
    entry->name   = NULL;
    entry->handle = NULL;
    return True;
  }
  
  return False;  
}

Here is the call graph for this function:

xxlib_draw_gray_image ( XlibRgbHandle *  handle,
Drawable  drawable,
GC  gc,
int  x,
int  y,
int  width,
int  height,
XlibRgbDither  dith,
unsigned char *  buf,
int  rowstride 
)

Definition at line 3827 of file xlibrgb.c.

{
  if (handle->bpp == 1 &&
      handle->gray_cmap == NULL &&
      (handle->x_visual_info->class == PseudoColor ||
       handle->x_visual_info->class == GrayScale))
    xxlib_rgb_make_gray_cmap (handle);
  
  if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL &&
                                      !handle->dith_default))
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                              buf, 1, rowstride,
                              handle->conv_gray, NULL, 0, 0);
  else
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                              buf, 1, rowstride,
                              handle->conv_gray_d, NULL, 0, 0);
}

Here is the call graph for this function:

xxlib_draw_indexed_image ( XlibRgbHandle *  handle,
Drawable  drawable,
GC  gc,
int  x,
int  y,
int  width,
int  height,
XlibRgbDither  dith,
unsigned char *  buf,
int  rowstride,
XlibRgbCmap *  cmap 
)

Definition at line 3891 of file xlibrgb.c.

{
  if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL &&
                                       !handle->dith_default))
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                               buf, 1, rowstride,
                               handle->conv_indexed, cmap, 0, 0);
  else
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                               buf, 1, rowstride,
                               handle->conv_indexed_d, cmap, 0, 0);
}

Here is the call graph for this function:

xxlib_draw_rgb_32_image ( XlibRgbHandle *  handle,
Drawable  drawable,
GC  gc,
int  x,
int  y,
int  width,
int  height,
XlibRgbDither  dith,
unsigned char *  buf,
int  rowstride 
)

Definition at line 3794 of file xlibrgb.c.

{
  if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL &&
                                       !handle->dith_default))
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                               buf, 4, rowstride,
                               handle->conv_32, NULL, 0, 0);
  else
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                               buf, 4, rowstride,
                               handle->conv_32_d, NULL, 0, 0);
}

Here is the call graph for this function:

xxlib_draw_rgb_image ( XlibRgbHandle *  handle,
Drawable  drawable,
GC  gc,
int  x,
int  y,
int  width,
int  height,
XlibRgbDither  dith,
unsigned char *  rgb_buf,
int  rowstride 
)

Definition at line 3748 of file xlibrgb.c.

{
  if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL &&
                                      !handle->dith_default))
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                              rgb_buf, 3, rowstride, handle->conv, NULL,
                              0, 0);
  else
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                              rgb_buf, 3, rowstride, handle->conv_d, NULL,
                              0, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_draw_rgb_image_dithalign ( XlibRgbHandle *  handle,
Drawable  drawable,
GC  gc,
int  x,
int  y,
int  width,
int  height,
XlibRgbDither  dith,
unsigned char *  rgb_buf,
int  rowstride,
int  xdith,
int  ydith 
)

Definition at line 3770 of file xlibrgb.c.

{
  if (dith == XLIB_RGB_DITHER_NONE || (dith == XLIB_RGB_DITHER_NORMAL &&
                                       !handle->dith_default))
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                              rgb_buf, 3, rowstride, handle->conv, NULL,
                              xdith, ydith);
  else
    xxlib_draw_rgb_image_core (handle, drawable, gc, x, y, width, height,
                               rgb_buf, 3, rowstride, handle->conv_d, NULL,
                               xdith, ydith);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_draw_xprint_scaled_rgb_image ( XlibRgbHandle *  handle,
Drawable  drawable,
long  paper_resolution,
long  image_resolution,
GC  gc,
int  x,
int  y,
int  width,
int  height,
XlibRgbDither  dith,
unsigned char *  rgb_buf,
int  rowstride 
)

Definition at line 3914 of file xlibrgb.c.

{
  long available = ((65536 < handle->max_request_size) ? 
                    (65536 << 1):(handle->max_request_size << 1))
                 - 512 /* SIZEOF(xPutImageReq) */;
                
  if (image_resolution == 0)
    image_resolution = paper_resolution;

  if( (rowstride * height) < available )
  {
    xxlib_draw_rgb_image(handle,
                         drawable,
                         gc,
                         x, y, width, height,
                         dith,
                         rgb_buf, rowstride);
  }
  else
  {
    int    subimageheight = available / rowstride;
    double scaling_factor = (double)paper_resolution / (double)image_resolution;

#ifdef DEBUG    
    printf("xxlib_draw_xprint_scaled_rgb_image: "
           "splitting image x=%d, y=%d, width=%d, height=%d, subimageheight=%d, scaling_factor=%g, max_request_size=%ld, available=%ld\n",
           x, y, width, height, subimageheight, scaling_factor, (long)handle->max_request_size, (long)available);
#endif /* DEBUG */

    if (subimageheight == 0)
        subimageheight = 1;

      xxlib_draw_xprint_scaled_rgb_image(handle,
                                         drawable,
                                         paper_resolution, image_resolution,
                                         gc,
                                         x, y,
                                         width, subimageheight,
                                         dith,
                                         rgb_buf,
                                         rowstride);

      xxlib_draw_xprint_scaled_rgb_image(handle,
                                         drawable,
                                         paper_resolution, image_resolution,
                                         gc,
                                         x, y+(int)((double)subimageheight*scaling_factor), 
                                         width, (height-subimageheight),
                                         dith,
                                         (rgb_buf+(subimageheight*rowstride)),
                                         rowstride);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_find_handle ( const char *  name)

Definition at line 4131 of file xlibrgb.c.

{
  RegisteredHandle *entry = xxlib_find_registered_handle(name);
  return (entry)?(entry->handle):(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_get_prec_from_mask ( unsigned  long)

Definition at line 394 of file xlibrgb.c.

{
  unsigned long retval = 0;
  unsigned int cur_bit = 0;
  /* walk through the number, incrementing the value if
     the bit in question is set. */
  while (cur_bit < (sizeof(unsigned long) * 8)) {
    if ((val >> cur_bit) & 0x1) {
      retval++;
    }
    cur_bit++;
  }
  return retval;
}

Here is the caller graph for this function:

xxlib_get_shift_from_mask ( unsigned  long)

Definition at line 410 of file xlibrgb.c.

{
  unsigned long cur_bit = 0;
  /* walk through the number, looking for the first 1 */
  while (cur_bit < (sizeof(unsigned long) * 8)) {
    if ((val >> cur_bit) & 0x1) {
      return cur_bit;
    }
    cur_bit++;
  }
  return cur_bit;
}

Here is the caller graph for this function:

xxlib_register_handle ( const char *  name,
XlibRgbHandle *  handle 
)

Definition at line 4055 of file xlibrgb.c.

{
  RegisteredHandle *entry = NULL;
  unsigned int i;
  
  if (xxlib_find_handle(name) || (handle == NULL))
    return False;
  
  /* search for a free slot... */  
  for( i=0 ; i < registered_handles_size ; i++ )
  {
    if (!registered_handles[i].handle)
    {
      entry = &registered_handles[i];
      break;
    }
  }
  
  /* ... no unused entry found ? Then allocate a new one... */
  if (!entry)
  {
    registered_handles_size++;
    registered_handles = realloc(registered_handles, sizeof(RegisteredHandle)*registered_handles_size);
  
    if (!registered_handles)
      abort();
    entry = &registered_handles[registered_handles_size-1];
  }

  entry->name   = strdup(name);
  entry->handle = handle;
  
  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_rgb_cmap_free ( XlibRgbHandle *  handle,
XlibRgbCmap *  cmap 
)

Definition at line 3885 of file xlibrgb.c.

{
  free (cmap);
}
xxlib_rgb_cmap_new ( XlibRgbHandle *  handle,
uint32 colors,
int  n_colors 
)

Definition at line 3855 of file xlibrgb.c.

{
  XlibRgbCmap *cmap;
  int i, j;
  uint32 rgb;

  if (n_colors < 0)
    return NULL;
  if (n_colors > 256)
    return NULL;
  cmap = malloc(sizeof(XlibRgbCmap));
  memcpy (cmap->colors, colors, n_colors * sizeof(uint32));
  if (handle->bpp == 1 &&
      (handle->x_visual_info->class == PseudoColor ||
       handle->x_visual_info->class == GrayScale))
    for (i = 0; i < n_colors; i++)
      {
        rgb = colors[i];
        j = ((rgb & 0xf00000) >> 12) |
                   ((rgb & 0xf000) >> 8) |
                   ((rgb & 0xf0) >> 4);
#ifdef VERBOSE
        printf ("%d %x %x %d\n", i, j, handle->colorcube[j]);
#endif
        cmap->lut[i] = handle->colorcube[j];
      }
  return cmap;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_rgb_create_handle ( Display display,
Screen *  screen,
XlibRgbArgs args 
)

Definition at line 965 of file xlibrgb.c.

{
  XlibRgbHandle *handle = NULL;
  int i;
  static const int byte_order[1] = { 1 };

#ifdef DEBUG
  printf("xxlib_rgb_create_handle: pseudogray=%d, install_colormap=%d, "
         "disallow_image_tiling=%d, disallow_mit_shmem=%d, verbose=%d\n",
         (int)args->pseudogray,
         (int)args->install_colormap,
         (int)args->disallow_image_tiling,
         (int)args->disallow_mit_shmem,
         (int)args->verbose);
#endif /* DEBUG */

  /* check endian sanity */
#if G_BYTE_ORDER == G_BIG_ENDIAN
  if (((char *)byte_order)[0] == 1) {
    fprintf (stderr, "xxlib_rgb_create_handle_with_depth: "
             "compiled for big endian, but this is a little endian machine.\n\n");
    abort();
  }
#else
  if (((char *)byte_order)[0] != 1) {
    fprintf (stderr, "xxlib_rgb_create_handle_with_depth: "
             "compiled for little endian, but this is a big endian machine.\n\n");
    abort();
  }
#endif /* G_BYTE_ORDER == G_BIG_ENDIAN */

#ifndef XLIBRGB_MIT_SHM_SUPPORT_HAS_BEEN_FIXED
    /* We still have issues with MIT_SHM support on LSB platforms... ;-( */
    args->disallow_mit_shmem = True;
#endif /* XLIBRGB_MIT_SHM_SUPPORT_HAS_BEEN_FIXED */    
       
    if (!(handle = malloc(sizeof(XlibRgbHandle))))
      return NULL;      
    memset(handle, 0, sizeof(XlibRgbHandle));

    /* should we register this handle ? */
    if (args->handle_name)
    {
      if (!xxlib_register_handle(args->handle_name, handle))
      {
#ifdef DEBUG
        puts("xxlib_rgb_create_handle: cannot register handle");
#endif /* DEBUG */      
        free(handle);
        return NULL;
      }  
    }
    
    /* Emulate StaticGray via PseudoColor visual ? */
    if (args->pseudogray)
    {
      args->xtemplate.class = PseudoColor;
      args->xtemplate.depth = 8;
      args->xtemplate_mask |= VisualClassMask|VisualDepthMask;
    } 
        
    handle->display = display;
    handle->screen = screen;
    handle->screen_num = XScreenNumberOfScreen(screen);
    handle->x_visual_info = NULL;
    handle->cmap = None;
    handle->default_visualid = XDefaultVisual(display, handle->screen_num);
    handle->default_colormap = XDefaultColormap(display, handle->screen_num);
    handle->max_request_size = XMaxRequestSize(display);

#ifdef XLIBRGB_ENABLE_MITSHM_SUPPORT
    xshm_image_check(handle, args);
#endif /* XLIBRGB_ENABLE_MITSHM_SUPPORT */
    handle->disallow_image_tiling  = args->disallow_image_tiling;
    handle->xlib_rgb_install_cmap  = args->install_colormap;
    
    handle->color_pixels = NULL;
    handle->gray_pixels = NULL;
    handle->reserved_pixels = NULL;

    handle->nred_shades = 6;
    handle->ngreen_shades = 6;
    handle->nblue_shades = 4;
    handle->ngray_shades = 24;
    handle->nreserved = 0;

    handle->bpp = 0;
    handle->cmap_alloced = False;
    handle->gamma_val = 1.0;

    handle->stage_buf = NULL;

    handle->own_gc = None;
    
    handle->red_shift = 0;
    handle->red_prec = 0;
    handle->green_shift = 0;
    handle->green_prec = 0;
    handle->blue_shift = 0;
    handle->blue_prec = 0;

    handle->xlib_rgb_min_colors = 5 * 5 * 5;

    handle->horiz_y = IMAGE_HEIGHT;
    handle->vert_x  = IMAGE_WIDTH;
    handle->tile_x  = IMAGE_WIDTH;
    handle->tile_y1 = IMAGE_HEIGHT;
    handle->tile_y2 = IMAGE_HEIGHT;  

    if (!xxlib_rgb_choose_visual (handle, &args->xtemplate, args->xtemplate_mask))
    {
#ifdef DEBUG
      puts("xxlib_rgb_choose_visual failure");
#endif /* DEBUG */
      xxlib_rgb_destroy_handle(handle);
      return NULL;
    }

    handle->bitmap = (handle->x_visual_info->depth == 1);
      
    /* set up the shift and the precision for the red, green and blue.
       this only applies to cool visuals like true color and direct color. */
    if (handle->x_visual_info->class == TrueColor ||
        handle->x_visual_info->class == DirectColor) {
      handle->red_shift   = xxlib_get_shift_from_mask(handle->x_visual_info->red_mask);
      handle->red_prec    = xxlib_get_prec_from_mask(handle->x_visual_info->red_mask);
      handle->green_shift = xxlib_get_shift_from_mask(handle->x_visual_info->green_mask);
      handle->green_prec  = xxlib_get_prec_from_mask(handle->x_visual_info->green_mask);
      handle->blue_shift  = xxlib_get_shift_from_mask(handle->x_visual_info->blue_mask);
      handle->blue_prec   = xxlib_get_prec_from_mask(handle->x_visual_info->blue_mask);
    }
    
    if (args->pseudogray)
    {
      if (handle->xlib_rgb_install_cmap)
      {
        handle->cmap = XCreateColormap(handle->display,
                                       XRootWindow(handle->display, handle->screen_num),
                                       handle->x_visual_info->visual,
                                       AllocNone);
        xxlib_rgb_set_gray_cmap (handle, handle->cmap);
        handle->cmap_alloced = TRUE;
      }
      else
      {
        handle->cmap = handle->default_colormap;
        xxlib_rgb_set_gray_cmap (handle, handle->cmap);
      }  
    }
    else if ((handle->x_visual_info->class == PseudoColor ||
           handle->x_visual_info->class == StaticColor) &&
           handle->x_visual_info->depth < 8 &&
           handle->x_visual_info->depth >= 3)
    {
      handle->cmap = handle->default_colormap;
      xxlib_rgb_colorcube_222 (handle);
    }
    else if (handle->x_visual_info->class == StaticColor)
    {
      handle->cmap = XCreateColormap(handle->display,
                                     XRootWindow(handle->display, handle->screen_num),
                                     handle->x_visual_info->visual,
                                     AllocNone);
      handle->cmap_alloced = TRUE;
      xxlib_rgb_colorcube_676(handle);
    }
    else if (handle->x_visual_info->class == PseudoColor)
    {
      if (handle->xlib_rgb_install_cmap ||
          handle->x_visual_info->visualid != handle->default_visualid->visualid)
      {
        handle->cmap = XCreateColormap(handle->display,
                                       XRootWindow(handle->display, handle->screen_num),
                                       handle->x_visual_info->visual,
                                       AllocNone);
        handle->cmap_alloced = TRUE;
      }
      
      if (!xxlib_rgb_do_colormaps (handle))
      {
        handle->cmap = XCreateColormap(handle->display,
                                       XRootWindow(handle->display, handle->screen_num),
                                       handle->x_visual_info->visual,
                                       AllocNone);
        handle->cmap_alloced = TRUE;
        xxlib_rgb_do_colormaps (handle);
      }
      if (handle->xlib_rgb_verbose)
        printf ("color cube: %d x %d x %d\n",
                handle->nred_shades,
                handle->ngreen_shades,
                handle->nblue_shades);

      if (!handle->cmap_alloced)
        handle->cmap = handle->default_colormap;
     }
#ifdef ENABLE_GRAYSCALE
    else if (handle->x_visual_info->class == GrayScale)
    {
      handle->cmap = XCreateColormap(handle->display,
                                     XRootWindow(handle->display, handle->screen_num),
                                     handle->x_visual_info->visual,
                                     AllocNone);
      xxlib_rgb_set_gray_cmap (handle, handle->cmap);
      handle->cmap_alloced = TRUE;
    }
#endif /* ENABLE_GRAYSCALE */
    else if (handle->x_visual_info->class != DirectColor && 
             handle->x_visual_info->visualid == handle->default_visualid->visualid)
    {
      handle->cmap = handle->default_colormap;
    }  
    else
    {
      /* Always install colormap in direct color. */
      handle->cmap = XCreateColormap(handle->display,
                                     XRootWindow(handle->display, handle->screen_num),
                                     handle->x_visual_info->visual,
                                     AllocNone);
      handle->cmap_alloced = TRUE;
    }

#ifdef XLIBRGB_ENABLE_MITSHM_SUPPORT
    if (handle->xlib_use_shm)
    {
      /* try to allocate N_IMAGES shm X images */
      for (i = 0; i < N_IMAGES; i++)
      {
        handle->static_image[i] = xshm_image_new(handle);
        if (!handle->static_image[i])
        {
          handle->xlib_use_shm = False;
          break;
        }
      }
      
      /* Failure ? Then clean-up and use the standard method below... */
      if (!handle->xlib_use_shm)
      {
#ifdef DEBUG
        printf("Failed to set-up MIT-SHMEM after %d images\n", i);
#endif /* DEBUG */
        for (i = 0; i < N_IMAGES; i++)
        {
          if (handle->static_image[i])
          {
            XDestroyImage(handle->static_image[i]);
            handle->static_image[i] = NULL;
          }  
        } 
      }
    }  

    /* Allocate "normal" images "*/
    if (!handle->xlib_use_shm)
#endif /* XLIBRGB_ENABLE_MITSHM_SUPPORT */
    {    
      for (i = 0; i < N_IMAGES; i++) 
      {
        handle->static_image[i] = xxlib_normal_ximage(handle);
      }
    }  

    /* ok, so apparently, handle->bpp is actually
     * BYTES per pixel.  What fun! */
    handle->bpp = (handle->static_image[0]->bits_per_pixel + 7) / 8;

    xxlib_rgb_select_conv (handle, handle->static_image[0], MSB_FIRST);
    
    return handle;
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_rgb_destroy_handle ( XlibRgbHandle *  handle)

Definition at line 918 of file xlibrgb.c.

{
  int i;

  for( i = 0 ; i < N_IMAGES ; i++ )
  {
    if (handle->static_image[i])
      XDestroyImage(handle->static_image[i]);
  }
  
  if (handle->cmap_alloced)
  {
    XFreeColormap(handle->display, handle->cmap);
  }
  
  if (handle->own_gc)
    XFreeGC(handle->display, handle->own_gc);
  
  if (handle->colorcube)
    free(handle->colorcube);

  if (handle->colorcube_d && (handle->colorcube_d != handle->colorcube))
    free(handle->colorcube_d);
  
  if (handle->DM_565)
    free(handle->DM_565);
  
  if (handle->stage_buf)
    free(handle->stage_buf);

  xxlib_deregister_handle_by_handle(handle);
  
#ifdef DEBUG
    /* force crash if someone tries to touch the handle... */
    memset(handle, 0, sizeof(XlibRgbHandle));
#endif  
            
  /* done... */
  free(handle); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_rgb_ditherable ( XlibRgbHandle *  handle)

Definition at line 3980 of file xlibrgb.c.

{
  return (handle->conv != handle->conv_d);
}
xxlib_rgb_gc_set_background ( XlibRgbHandle *  handle,
GC  gc,
uint32  rgb 
)

Definition at line 1313 of file xlibrgb.c.

{
  unsigned long color;

  color = xxlib_rgb_xpixel_from_rgb (handle, rgb);
  XSetBackground(handle->display, gc, color);
}

Here is the call graph for this function:

xxlib_rgb_gc_set_foreground ( XlibRgbHandle *  handle,
GC  gc,
uint32  rgb 
)

Definition at line 1304 of file xlibrgb.c.

{
  unsigned long color;

  color = xxlib_rgb_xpixel_from_rgb (handle, rgb);
  XSetForeground(handle->display, gc, color);
}

Here is the call graph for this function:

xxlib_rgb_get_cmap ( XlibRgbHandle *  handle)

Definition at line 3986 of file xlibrgb.c.

{
  return (handle)?(handle->cmap):(None);
}

Here is the caller graph for this function:

xxlib_rgb_get_depth ( XlibRgbHandle *  handle)

Definition at line 4006 of file xlibrgb.c.

{
  XVisualInfo *v = xxlib_rgb_get_visual_info(handle);

  return (v)?(v->depth):(0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

xxlib_rgb_get_display ( XlibRgbHandle *  handle)

Definition at line 4014 of file xlibrgb.c.

{ 
  return (handle)?(handle->display):(NULL);
}

Here is the caller graph for this function:

xxlib_rgb_get_screen ( XlibRgbHandle *  handle)

Definition at line 4020 of file xlibrgb.c.

{
  return (handle)?(handle->screen):(NULL);
}

Here is the caller graph for this function:

xxlib_rgb_get_visual ( XlibRgbHandle *  handle)

Definition at line 3992 of file xlibrgb.c.

{
  /* xxlib_rgb_init (); */
  return (handle)?(handle->x_visual_info->visual):(NULL);
}

Here is the caller graph for this function:

xxlib_rgb_get_visual_info ( XlibRgbHandle *  handle)

Definition at line 3999 of file xlibrgb.c.

{
  /* xxlib_rgb_init (); */
  return (handle)?(handle->x_visual_info):(NULL);
}

Here is the caller graph for this function:

xxlib_rgb_set_min_colors ( XlibRgbHandle *  handle,
int  min_colors 
)

Definition at line 731 of file xlibrgb.c.

{
  handle->xlib_rgb_min_colors = min_colors;
}
xxlib_rgb_set_verbose ( XlibRgbHandle *  handle,
Bool  verbose 
)

Definition at line 725 of file xlibrgb.c.

{
  handle->xlib_rgb_verbose = verbose;
}
xxlib_rgb_xpixel_from_rgb ( XlibRgbHandle *  handle,
uint32  rgb 
)

Definition at line 1240 of file xlibrgb.c.

{
  unsigned long pixel = 0;

  if (handle->bitmap)
  {
    return ((rgb & 0xff0000) >> 16) +
           ((rgb & 0xff00) >> 7) +
            (rgb & 0xff) > 510;
  }
  else if (handle->x_visual_info->class == PseudoColor)
    pixel = handle->colorcube[((rgb & 0xf00000) >> 12) |
                              ((rgb & 0xf000) >> 8) |
                              ((rgb & 0xf0) >> 4)];
  else if (handle->x_visual_info->depth < 8 &&
           handle->x_visual_info->class == StaticColor)
  {
    pixel = handle->colorcube_d[((rgb & 0x800000) >> 17) |
                                ((rgb & 0x8000) >> 12) |
                                ((rgb & 0x80) >> 7)];
  }
  else if (handle->x_visual_info->class == StaticColor)
  {
    pixel = handle->colorcube[((rgb & 0xf00000) >> 12) |
                              ((rgb & 0xf000) >> 8) |
                              ((rgb & 0xf0) >> 4)];  
  }
  else if (handle->x_visual_info->class == TrueColor ||
           handle->x_visual_info->class == DirectColor)
  {
#ifdef VERBOSE
    printf ("shift, prec: r %d %d g %d %d b %d %d\n",
            handle->red_shift,
            handle->red_prec,
            handle->green_shift,
            handle->green_prec,
            handle->blue_shift,
            handle->blue_prec);
#endif

    pixel = (((((rgb & 0xff0000) >> 16) >>
               (8 - handle->red_prec)) <<
              handle->red_shift) +
             ((((rgb & 0xff00) >> 8)  >>
               (8 - handle->green_prec)) <<
              handle->green_shift) +
             (((rgb & 0xff) >>
               (8 - handle->blue_prec)) <<
              handle->blue_shift));
  }
  else if (handle->x_visual_info->class == StaticGray ||
           handle->x_visual_info->class == GrayScale)
  {
    int gray = ((rgb & 0xff0000) >> 16) +
               ((rgb & 0xff00) >> 7) +
                (rgb & 0xff);

    return gray >> (10 - handle->x_visual_info->depth);
  }

  return pixel;
}

Here is the caller graph for this function:


Variable Documentation

_XFUNCPROTOBEGIN typedef unsigned int uint32

Definition at line 99 of file xlibrgb.h.