The "kcmap" Package

These routines are meant to provide a high level mechanism to create and manipulate colourmaps, complete with colourmap sharing, dynamic allocation and event management.

Library: karma
Link With: -lkarma

Functions

kcmap_initialiseThis routine will initialise the package.
kcmap_va_createCreate a high level colourmap.
kcmap_destroyDestroy a colourmap.
kcmap_register_destroy_funcRegister destroy callback.
kcmap_add_RGB_funcRegister a new colourmap function.
kcmap_add_grey_funcRegister a new colourmap function.
kcmap_register_resize_funcRegister a colourmap resize function.
kcmap_register_modify_funcRegister a colourmap modify function.
kcmap_changeChange active colourmap function.
kcmap_modifyChange colours in a colourmap.
kcmap_modify_direct_typeChange colours in a colourmap.
kcmap_list_funcsGet list of colourmap functions.
kcmap_get_funcs_for_cmapGet list of colourmap functions compatible with a colourmap.
kcmap_get_active_funcGet active colourmap function.
kcmap_get_pixelsGet pixel values in a colourmap.
kcmap_notify_pixels_changedNotify that pixel values have been changed.
kcmap_get_pixelThis routine will get a numbered pixel value from a colourmap.
kcmap_prepare_for_slaveryAllow colourmap to be slaved.
kcmap_prepare_for_masteryAllow colourmap to be slaved.
kcmap_copy_to_structCopy colour data from a colourmap.
kcmap_copy_from_structCopy colour data into a colourmap.
kcmap_get_rgb_valueGet colour data from a colourmap.
kcmap_get_rgb_valuesGet colour data from a colourmap.
kcmap_read_rgb_valuesGet RGB values in a colourmap.
kcmap_write_rgb_valuesWrite RGB values to a colourmap.
kcmap_get_attributesThis routine will get the attributes for a colourmap.
kcmap_set_attributesThis routine will set the attributes for a colourmap.
kcmap_register_att_notify_funcRegister an attribute change function.
kcmap_get_dpy_handleGet the Kdisplay object for a colourmap.

Prototype Functions

kcmap_PROTO_alloc_funcAllocate colourcells.
kcmap_PROTO_free_funcFree colourcells.
kcmap_PROTO_store_funcThis routine will store colours into a low level colourmap.
kcmap_PROTO_location_funcGet location of display.
kcmap_PROTO_colour_funcModify colour values.
kcmap_PROTO_grey_funcModify greyscale colour values.
kcmap_PROTO_destroy_funcProcess a destroy event for an object.
kcmap_PROTO_modify_funcThis routine registers a change in the colourmap values.
kcmap_PROTO_att_notify_funcThis routine registers a change in the attributes of a colourmap.

Tables

kcmap_ATTRIBUTESList of attributes for Kcolourmap objects


Functions


EXPERIMENTAL FUNCTION: subject to change without notice

void kcmap_initialise ()

This routine will initialise the package.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Kcolourmap kcmap_va_create (CONST char *name, unsigned int num_cells, flag tolerant, Kdisplay dpy_handle, unsigned int (*alloc_func) (), void (*free_func) (), void (*store_func) (), void (*location_func) (), ...)

This routine will create a high level colourmap. The colourmap may be associated with a hardware colourmap, or it may be a software-only colourmap. In either case, storage for an array of pixel values and arrays of colour components is maintained within the colourmap object.

Parameters:

Returns: A colourmap on success, else NULL.
Multithreading Level: Unsafe
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

void kcmap_destroy (Kcolourmap cmap)

Destroy a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

KCallbackFunc kcmap_register_destroy_func (Kcolourmap cmap, void (*func) (), void *info)

This routine will register a destroy function for a colourmap. This is called when kcmap_destroy is called. Many destroy functions may be registered per colourmap. The first function registered is the first function called upon destruction.

Parameters:

Returns: A KCallbackFunc object. On failure, the process aborts.
Multithreading Level: Unsafe


void kcmap_add_RGB_func (CONST char *name, void (*func) (), unsigned int min_cells, unsigned int max_cells)

This routine will register a named function which will compute RGB intensity values for a colourmap. This function is typically called in response to a call to kcmap_modify.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void kcmap_add_grey_func (CONST char *name, void (*func) (), unsigned int min_cells, unsigned int max_cells)

This routine will register a named function which will compute RGB intensity values for a colourmap. This function is typically called in response to a call to kcmap_modify.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


KCallbackFunc kcmap_register_resize_func (Kcolourmap cmap, void (*resize_func) (), void *info)

This routine will register a resize callback function for a high level colourmap. The function will be called whenever the colourmap is resized. If the colourmap is a software colourmap, the function is called whenever the colour values change. Many resize callbacks may be registered per colourmap. The first function registered is the first function called upon resize.

Parameters:

Returns: A KCallbackFunc object.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

KCallbackFunc kcmap_register_modify_func (Kcolourmap cmap, void (*modify_func) (), void *info)

This routine will register a modify callback function for a high level colourmap. The function will be called whenever the colourmap is modified. Many modify callbacks may be registered per colourmap. The first function registered is the first function called upon modify.

Parameters:

Returns: A KCallbackFunc object.
Multithreading Level: Unsafe


flag kcmap_change (Kcolourmap cmap, CONST char *new_name, unsigned int num_cells, flag tolerant)

This routine will change the active function (algorithm) used to calculate the colours in a colourmap and the size of the colourmap.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


void kcmap_modify (Kcolourmap cmap, double x, double y, void *var_param)

This routine will call the active colour compute function to change the colourmap colours in a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


void kcmap_modify_direct_type (Kcolourmap cmap, double red_x, double red_y, void *red_var_param, double green_x, double green_y, void *green_var_param, double blue_x, double blue_y, void *blue_var_param)

This routine will call the active colour compute function to change the colourmap colours in a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


CONST char ** kcmap_list_funcs ()

This routine will get the array of supported colour function names. This array is dynamically allocated, and should be freed using m_free. The array is terminated with a NULL pointer.

Parameters:

Returns: A pointer to the array.
Multithreading Level: Unsafe
Note:


CONST char ** kcmap_get_funcs_for_cmap (Kcolourmap cmap)

This routine will get the array of supported colour function names. This array is dynamically allocated, and should be freed using m_free. The array is terminated with a NULL pointer. Only functions which are compatible with the colourmap are returned.

Parameters:

Returns: A pointer to the array.
Multithreading Level: Unsafe
Note:


CONST char * kcmap_get_active_func (Kcolourmap cmap)

This routine will get the name of the active colour function for a colourmap.

Parameters:

Returns: A pointer to the name of the colour function. This name must not be freed.
Multithreading Level: Unsafe


unsigned int kcmap_get_pixels (Kcolourmap cmap, unsigned long **pixel_values)

This routine will determine the number of colourcells in a colourmap and the pixel values allocated.

Parameters:

Returns: The number of colourcells allocated.
Multithreading Level: Unsafe


void kcmap_notify_pixels_changed (Kcolourmap cmap)

This routine posts a notification that the pixel values in a software colourmap have changed. The resize functions registered with kcmap_register_resize_func are usually called.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


unsigned long kcmap_get_pixel (Kcolourmap cmap, unsigned int index)

This routine will get a numbered pixel value from a colourmap.

Parameters:

Returns: The pixel value.
Multithreading Level: Unsafe


void kcmap_prepare_for_slavery (Kcolourmap cmap)

This routine will register a colourmap to be the choosen colourmap for subsequent attempts to open a slave colourmap connection. In order to make the colourmap a slave, a subsequent call to conn_attempt_connection must be made.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void kcmap_prepare_for_mastery (Kcolourmap cmap)

This routine will register a colourmap to be the choosen colourmap for subsequent attempts to open a slave colourmap connection. In order to make the colourmap a slave, a subsequent call to conn_attempt_connection must be made.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


flag kcmap_copy_to_struct (Kcolourmap cmap, packet_desc **top_pack_desc, char **top_packet)

This routine will copy the colour data in a colourmap into a newly allocated Karma data structure. This data structure may be subsequently deallocated.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag kcmap_copy_from_struct (Kcolourmap cmap, packet_desc *top_pack_desc, char *top_packet)

This routine will copy the colour data in a Karma data structure into a colourmap. If the colourmap changes size, then the resize_func registered is called.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void kcmap_get_rgb_value (Kcolourmap cmap, unsigned int index, unsigned short *red, unsigned short *green, unsigned short *blue)

This routine will return an RGB value in a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


unsigned short * kcmap_get_rgb_values (Kcolourmap cmap, unsigned int *size)

This routine will return the RGB values in a colourmap. The colour values are arranged in packets of Red, Green and Blue values.

Parameters:

Returns: A pointer to a dynamically allocated array. This must be freed with m_free. On failure it returns NULL.
Multithreading Level: Unsafe


unsigned int kcmap_read_rgb_values (Kcolourmap cmap, unsigned int num, unsigned short *red, unsigned short *green, unsigned short *blue, unsigned int stride)

Get RGB values in a colourmap.

Parameters:

Returns: The number of RGB values written.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag kcmap_write_rgb_values (Kcolourmap cmap, unsigned int num_values, CONST unsigned short *reds, CONST unsigned short *greens, CONST unsigned short *blues, unsigned int stride)

This routine will write ther data into a colourmap. If the colourmap changes size, then the resize_func registered is called.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


void kcmap_get_attributes (Kcolourmap cmap, ...)

This routine will get the attributes for a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_set_attributes (Kcolourmap cmap, ...)

This routine will set the attributes for a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

KCallbackFunc kcmap_register_att_notify_func (Kcolourmap cmap, void (*func) (), void *info)

This routine will register an attribute notify function for a high level colourmap. The attribute notify function will be called whenever the colourmap attributes are changed (see kcmap_set_attributes). Many attribute notify functions may be registered per colourmap. The first function registered is the first function called upon attribute changes.

Parameters:

Returns: A KCallbackFunc object.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

Kdisplay kcmap_get_dpy_handle (Kcolourmap cmap)

Get the Kdisplay object for a colourmap.

Parameters:

Returns: A Kdisplay object.
Multithreading Level: Unsafe


Prototype Functions


unsigned int kcmap_PROTO_alloc_func (unsigned int num_cells, unsigned long *pixel_values, unsigned int min_cells, Kdisplay dpy_handle)

This routine will allocate a number of colourcells in a low level colourmap (e.g. using the Xlib routine XAllocColorCells).

Parameters:

Returns: The number of colourcells allocated.
Multithreading Level: Unsafe


void kcmap_PROTO_free_func (unsigned int num_cells, unsigned long *pixel_values, Kdisplay dpy_handle)

This routine will free a number of colourcells in a low level colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_PROTO_store_func (unsigned int num_cells, unsigned long *pixel_values, unsigned short *reds, unsigned short *greens, unsigned short *blues, unsigned int stride, Kdisplay dpy_handle)

This routine will store colours into a low level colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_PROTO_location_func (Kdisplay dpy_handle, unsigned long *serv_hostaddr, unsigned long *serv_display_num, unsigned long *cmap_id)

This routine will determine the location of the graphics display being used.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_PROTO_colour_func (unsigned int num_cells, unsigned short *reds, unsigned short *greens, unsigned short *blues, unsigned int stride, double x, double y, void *var_param)

This routine will write RGB colour intensity values to a number of colourcells. This routine is called in response to a call to kcmap_modify.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_PROTO_grey_func (unsigned int num_cells, unsigned short *reds, unsigned short *greens, unsigned short *blues, unsigned int stride, double x, double y, void *var_param)

This routine will write greyscale intensity values to a number of colourcells. This routine is called in response to a call to kcmap_modify.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


flag kcmap_PROTO_destroy_func (void *info)

Process a destroy event for an object.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_PROTO_modify_func (Kcolourmap cmap, void **info)

This routine registers a change in the colourmap values.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void kcmap_PROTO_att_notify_func (Kcolourmap cmap, void **info)

This routine registers a change in the attributes of a colourmap.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Tables


kcmap_ATTRIBUTES List of attributes for Kcolourmap objects

Name Get Type Set Type Meaning
KCMAP_ATT_END End of varargs list
KCMAP_ATT_REVERSE flag * flag Reverse pixel order
KCMAP_ATT_INVERT flag * flag Invert intensities
KCMAP_ATT_SOFTWARE flag * Test if software colourmap
KCMAP_ATT_DPY_HANDLE Kdisplay * Get display handle
KCMAP_ATT_DIRECT_VISUAL flag * flag Handle colourmap as for a direct visual type
KCMAP_ATT_RED_SCALE unsigned int * unsigned int Red scale
KCMAP_ATT_GREEN_SCALE unsigned int * unsigned int Green scale
KCMAP_ATT_BLUE_SCALE unsigned int * unsigned int Blue scale
KCMAP_ATT_STEAL_COLOURS_FROM unsigned int * unsigned int Colourmap to steal colours from


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services