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_va_createCreate a high level colourmap.
kcmap_add_RGB_funcRegister a new colourmap function.
kcmap_register_resize_funcRegister a colourmap resize 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_copy_to_structCopy colour data from a colourmap.
kcmap_copy_from_structCopy colour data into a colourmap.
kcmap_get_rgb_valuesGet colour data from a colourmap.
kcmap_get_attributesThis routine will get the attributes for a colourmap.
kcmap_set_attributesThis routine will set the attributes 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_resize_funcThis routine registers a change in the size of a colourmap.

Tables

KCMAP_ATTRIBUTESList of attributes for Kcolourmap objects


Functions


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:


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


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

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

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


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


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


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:


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)

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


void KCMAP_PROTO_resize_func (Kcolourmap cmap, void **info)

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

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Tables


KCMAP_ATTRIBUTES

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 short * unsigned short Red scale
KCMAP_ATT_GREEN_SCALE unsigned short * unsigned short Green scale
KCMAP_ATT_BLUE_SCALE unsigned short * unsigned short Blue scale


Contact: Richard Gooch
Web Development: Ariel Internet Services