ImlibData *id;
ImlibImage *im;
ImlibColorModifier mod;
double gamma,brightness,contrast;
Imlib_get_image_modifier(id,im,&mod);
gamma=(double)mod.gamma/256;
brightness=(double)mod.brightness/256;
contrast=(dobule)mod.contrast/256;
Imlib_set_image_modifier(id,im,&mod);
GdkImlibImage *im;
GdkImlibColorModifier mod;
double gamma,brightness,contrast;
gdk_imlib_get_image_modifier(im,&mod);
gamma=(double)mod.gamma/256;
brightness=(double)mod.brightness/256;
contrast=(double)mod.contrast/256;
gdk_imlib_set_image_modifier(im,&mod);
Note that the contrast, brightness and gamma values are in fact int's. A value of 1.0 (unmodified verbatim data) is in fact 256, so to use a value of 0.5 for any of these, you would have to use a value of 128 etc.
When you set the modifiers, the map-tables (the curves) are re-calculated for that image. You have to re-render the image to gain a pixmap with these settings in effect.
There are also identical modifier settings for the red, green and blue channels, so these can be used for white point adjustment and other functions.
It is also possible to gain direct access to these map-table curves and set the values in them manually for finer control. There are 3 tables - one for red, one for green and one for blue. The functions
Imlib_set_image_red_curve
Imlib_set_image_green_curve
Imlib_set_image_blue_curve
Imlib_get_image_red_curve
Imlib_get_image_green_curve
Imlib_get_image_blue_curve
gdk_imlib_set_image_red_curve
gdk_imlib_set_image_green_curve
gdk_imlib_set_image_blue_curve
gdk_imlib_get_image_red_curve
gdk_imlib_get_image_green_curve
gdk_imlib_get_image_blue_curve
will set and get these. You pass the pointer to an array of 256 unsigned char's as the last parameter in each of these functions to have Imlib fill that table's contents or use that table's contents.
By default the map-table is linear if the global gamma, brightness and contrast settings are all normal (ie at 256). This would produce a mapping table such as the one here on the left. There is a table per channel describing this mapping. If you want you could set the table per red, green and blue channel to perhaps something like the graph below, that would then give a more interesting mapping. The tables for each channel can be different, and so could be used for re-coloring images in interesting ways.
It is also possible to then use these mappings to in fact modify the original 24-bit data for the image - making the changes permanent, and thus not needing and of the modifiers. To do this you would call the Imlib_apply_modifiers_to_rgb or gdk_imlib_apply_modifiers_to_rgb functions.If you need advanced manipulation of the 24-bit data (eg blurring, other convolutions etc.) you may do this to your heart's content. Just remember - before you render any pixmaps to call Imlib_changed_image or gdk_imlib_changed_image which will prevent Imlib's caching form not updating the pixmaps. This marks all pixmaps rendered off that image as being "dirty" and so they will never be referenced again by Imlib's caching. Once they are all freed and their reference counts are zero, they will be freed from memory.