![]() |
Oyranos
0.9.7
Oyranos is a full featured Color Management System
|
Easy to use API to generate matrix and LUT ICC profiles. More...
Modules | |
Samplers | |
Macros | |
#define | LCM2PROFILER_MAJOR 1 |
major version More... | |
#define | LCM2PROFILER_MINOR 0 |
minor version More... | |
#define | LCM2PROFILER_MICRO 0 |
patch version More... | |
#define | LCM2PROFILER_API (LCM2PROFILER_MAJOR*10000 + LCM2PROFILER_MINOR*100 + LCM2PROFILER_MICRO) |
compile time API Version More... | |
#define | ICC_2011_LICENSE "This profile is made available by %s, with permission of %s, and may be copied, distributed, embedded, made, used, and sold without restriction. Altered versions of this profile shall have the original identification and copyright information removed and shall not be misrepresented as the original profile." |
ICC 2011 license template. More... | |
Typedefs | |
typedef void(* | lcm2Sampler_f) (const double i[], double o[], void *vars) |
Manipulation function type. More... | |
Functions | |
cmsHPROFILE | lcm2OpenProfileFile (const char *my_space_profile, const char *my_space_profile_path) |
Open a profile from file. More... | |
char * | lcm2WriteProfileToFile (cmsHPROFILE my_space_profile, const char *my_space_profile_name, const char *my_space_profile_version, const char *vendor_four_bytes) |
Write a profile to a file. More... | |
void * | lcm2WriteProfileToMem (cmsHPROFILE *profile, size_t *size, void *(*allocateFunc)(size_t size)) |
int | lcm2CreateProfileLutByFunc (cmsHPROFILE profile, lcm2Sampler_f samplerMySpace, void *samplerArg, const char *in_space_profile, const char *my_space_profile, const char *out_space_profile, int grid_size, cmsTagSignature tag_sig) |
Generate a ICC profile LUT. More... | |
int | lcm2CreateProfileLutByFuncAndCurves (cmsHPROFILE profile, lcm2Sampler_f samplerMySpace, void *samplerArg, cmsToneCurve *in_curves[], cmsToneCurve *out_curves[], const char *in_space_profile, const char *my_space_profile, const char *out_space_profile, int grid_size, cmsTagSignature tag_sig) |
Generate a ICC profile LUT. More... | |
int | lcm2CreateAbstractProfile (lcm2Sampler_f samplerMySpace, void *samplerArg, const char *my_space_profile, int grid_size, double icc_profile_version, const char *my_abstract_description, const char **my_abstract_descriptions, const char *my_abstract_file_name, const char *provider, const char *vendor, const char *my_license, const char *device_model, const char *device_manufacturer, const char **my_meta_data, cmsHPROFILE *h_profile) |
Create a effect profile of type abstract in ICC*Lab PCS. More... | |
int | lcm2CreateAbstractTemperatureProfile (float kelvin, cmsHPROFILE source_white_profile, int grid_size, double icc_profile_version, char **my_abstract_file_name, cmsHPROFILE *h_profile) |
Create a effect profile of type abstract in ICC*Lab PCS from Kelvin. More... | |
int | lcm2CreateAbstractWhitePointProfileLab (double cie_a, double cie_b, int grid_size, double icc_profile_version, char **my_abstract_file_name, cmsHPROFILE *h_profile) |
Create a effect profile of type abstract in ICC*Lab PCS for white point adjustment. More... | |
int | lcm2CreateAbstractWhitePointProfileBradford (double *src_iccXYZ, double *illu_iccXYZ, int grid_size, double icc_profile_version, char **my_abstract_file_name, cmsHPROFILE *h_profile) |
Create a effect profile of type abstract in ICC*Lab PCS for white point adjustment. More... | |
cmsHPROFILE | lcm2CreateProfileFragment (const char *in_space_profile, const char *out_space_profile, double icc_profile_version, const char *my_abstract_description, const char *provider, const char *vendor, const char *my_license, const char *device_model, const char *device_manufacturer, cmsHPROFILE h_profile) |
Create a color profile starter. More... | |
void | lcm2AddMluDescription (cmsHPROFILE profile, const char *texts[], cmsTagSignature tag_sig) |
Add translated texts to a profile. More... | |
void | lcm2AddMetaTexts (cmsHPROFILE profile, const char *prefixes, const char *key_value[], cmsTagSignature tag_sig) |
Add meta data to a profile. More... | |
cmsHPROFILE | lcm2CreateICCMatrixProfile2 (float gamma, float rx, float ry, float gx, float gy, float bx, float by, float wx, float wy) |
Create a profile from primaries, white point and one gamma value. More... | |
int | lcm2MessageFunc (int code OY_UNUSED, const void *context_object OY_UNUSED, const char *format,...) |
default message function to console More... | |
int | lcm2MessageFuncSet (lcm2Message_f message_func) |
set a custom message function More... | |
int | lcm2Version () |
run time API version More... | |
Easy to use API to generate matrix and LUT ICC profiles.
Oyranos ICC Profiler API provides a platformindependent C interface to generate ICC profiles. It's main purpose is to generate ICC Profiles in a programatic way. The only dependency is littleCMS 2 www.littlecms.com. It reduces the need of many of the lcms2 boilerplate for format independent sampling, multi localised strings from UTF8 and more. The sampler collection contains effects and color space converters. The code consists of one source file and a header. So it can easily be placed inside your project.
The Oyranos ICC Profiler API is contained in the lcm2_profiler.h header file.
The high level API takes few arguments and generates a profile in one go. Effect profiles can be created in one call by lcm2CreateAbstractProfile(). It needs a Samplers function, which fills the Look Up Table (LUT). Two APIs exist to generate white point effects, lcm2CreateAbstractTemperatureProfile() and lcm2CreateAbstractWhitePointProfileLab() or lcm2CreateAbstractWhitePointProfileBradford(). These above high level APIs allow to write the profile to disc in one go.
The lower level APIs can be used to customise the profile generation. Basic matrix/shaper profiles can be created with lcm2CreateICCMatrixProfile2() and filled with custom texts in lcm2CreateProfileFragment().
The following low level code sample comes from lcm2_profiler.c. The code sets up a basic profile description and color spaces:
Profile i/o happens with lcm2OpenProfileFile(), which takes file names and a few wildcards as arguments. lcm2WriteProfileToFile() helps writing of canonical profile names. lcm2WriteProfileToMem() writes a profile to a custom memory allocator.
Most of the functions come with examples.
#define ICC_2011_LICENSE "This profile is made available by %s, with permission of %s, and may be copied, distributed, embedded, made, used, and sold without restriction. Altered versions of this profile shall have the original identification and copyright information removed and shall not be misrepresented as the original profile." |
ICC 2011 license template.
#define LCM2PROFILER_API (LCM2PROFILER_MAJOR*10000 + LCM2PROFILER_MINOR*100 + LCM2PROFILER_MICRO) |
compile time API Version
#define LCM2PROFILER_MAJOR 1 |
major version
#define LCM2PROFILER_MICRO 0 |
patch version
#define LCM2PROFILER_MINOR 0 |
minor version
typedef void(* lcm2Sampler_f) (const double i[], double o[], void *vars) |
Manipulation function type.
A pure function based sampler in double precission. i and o can be in different color spaces.
void lcm2AddMetaTexts | ( | cmsHPROFILE | profile, |
const char * | prefixes, | ||
const char * | key_value[], | ||
cmsTagSignature | tag_sig | ||
) |
Add meta data to a profile.
Function lcm2AddMetaTexts
Iterates over the provided string list converts from "UTF-8" input to "WCHAR_T" for lcms and does byteswapping on little endian machines.
Here a code example:
A prefix allows for grouping of keys like "EDID_" or "EXIF_". The prefix part might be cut off in some cases to access an other level of keys. Think of "EDID_model" for monitors and "EXIF_model" for cameras, which both represent the key "model" concept.
[in,out] | profile | color profile |
[in] | prefixes | The used uppercase prefix list. |
[in] | key_value | key + value list |
[in] | tag_sig | signature |
Referenced by lcm2CreateAbstractProfile().
void lcm2AddMluDescription | ( | cmsHPROFILE | profile, |
const char * | texts[], | ||
cmsTagSignature | tag_sig | ||
) |
Add translated texts to a profile.
Function lcm2AddMluDescription
Iterates over the provided string list converts from "UTF-8" input to "WCHAR_T" for lcms and does byteswapping on little endian machines.
Here a code example:
[in,out] | profile | color profile |
[in] | texts | language + country + text list |
[in] | tag_sig | signature |
Referenced by lcm2CreateAbstractProfile().
int lcm2CreateAbstractProfile | ( | lcm2Sampler_f | samplerMySpace, |
void * | samplerArg, | ||
const char * | my_space_profile, | ||
int | grid_size, | ||
double | icc_profile_version, | ||
const char * | my_abstract_description, | ||
const char ** | my_abstract_descriptions, | ||
const char * | my_abstract_file_name, | ||
const char * | provider, | ||
const char * | vendor, | ||
const char * | my_license, | ||
const char * | device_model, | ||
const char * | device_manufacturer, | ||
const char ** | my_meta_data, | ||
cmsHPROFILE * | h_profile | ||
) |
Create a effect profile of type abstract in ICC*Lab PCS.
Function lcm2CreateAbstractProfile
Here a code example:
[in] | samplerMySpace | the function to fill the LUT with color |
[in] | samplerArg | data pointer to samplerMySpace |
[in] | my_space_profile | operating color space for samplerMySpace(); "*lab" will set CIE*Lab |
[in] | grid_size | dimensions of the created LUT; e.g. 33 |
[in] | icc_profile_version | 2.3 or 4.3 |
[in] | my_abstract_description | internal profile name |
[in] | my_abstract_descriptions | internal profile name translated |
[in] | my_abstract_file_name | profile file name. If present a ICC profile will be written to that name. optional |
[in] | provider | e.g. "My Project 2016" |
[in] | vendor | e.g. "My Name" |
[in] | my_license | e.g. "This profile is made available by %s, with permission of %s, and may be copied, distributed, embedded, made, used, and sold without restriction. Altered versions of this profile shall have the original identification and copyright information removed and shall not be misrepresented as the original profile."
|
[in] | device_model | e.g. "My Set" |
[in] | device_manufacturer | e.g. "www.mydomain.net" |
[in] | my_meta_data | e.g. {"DOMAIN_,GROUP_","DOMAIN_key1","value1","GROUP_key2","value2"} |
[out] | h_profile | the resulting profile |
References lcm2AddMetaTexts(), lcm2AddMluDescription(), lcm2CreateProfileFragment(), and lcm2CreateProfileLutByFunc().
int lcm2CreateAbstractTemperatureProfile | ( | float | kelvin, |
cmsHPROFILE | source_white_profile, | ||
int | grid_size, | ||
double | icc_profile_version, | ||
char ** | my_abstract_file_name, | ||
cmsHPROFILE * | h_profile | ||
) |
Create a effect profile of type abstract in ICC*Lab PCS from Kelvin.
Function lcm2CreateAbstractTemperatureProfile
[in] | kelvin | the desired temperature in Kelvin; ICC reference (D50) is 5000 Kelvin |
[in] | source_white_profile | a profile, e.g. the actual monitor profile; optional, default is D50 |
[in] | grid_size | dimensions of the created LUT; e.g. 33 |
[in] | icc_profile_version | 2.3 or 4.3 |
[out] | my_abstract_file_name | profile file name |
[out] | h_profile | the resulting profile; If omitted the function will write the profile to my_abstract_file_name. |
int lcm2CreateAbstractWhitePointProfileBradford | ( | double * | src_iccXYZ, |
double * | illu_iccXYZ, | ||
int | grid_size, | ||
double | icc_profile_version, | ||
char ** | my_abstract_file_name, | ||
cmsHPROFILE * | h_profile | ||
) |
Create a effect profile of type abstract in ICC*Lab PCS for white point adjustment.
Function lcm2CreateAbstractWhitePointProfileBradford
These profiles can be applied to 1D / per single channel only adjustments. It will be marked with EFFECT_linear=yes in the meta tag.
[in] | source_white_profile | profile with media white point as source |
[in] | illu_iccXYZ | ICC*XYZ illuminant in 0.0 - 2.0 range |
[in] | grid_size | dimensions of the created LUT; e.g. 33 |
[in] | icc_profile_version | 2.3 or 4.3 |
[out] | my_abstract_file_name | profile file name |
[out] | h_profile | the resulting profile; If omitted the function will write the profile to my_abstract_file_name. |
int lcm2CreateAbstractWhitePointProfileLab | ( | double | cie_a, |
double | cie_b, | ||
int | grid_size, | ||
double | icc_profile_version, | ||
char ** | my_abstract_file_name, | ||
cmsHPROFILE * | h_profile | ||
) |
Create a effect profile of type abstract in ICC*Lab PCS for white point adjustment.
Function lcm2CreateAbstractWhitePointProfileLab
These profiles can be applied to 1D / per single channel only adjustments. It will be marked with EFFECT_linear=yes in the meta tag.
[in] | cie_a | CIE*a correction value in -0.5 - 0.5 range |
[in] | cie_b | CIE*b correction value in -0.5 - 0.5 range |
[in] | grid_size | dimensions of the created LUT; e.g. 33 |
[in] | icc_profile_version | 2.3 or 4.3 |
[out] | my_abstract_file_name | profile file name |
[out] | h_profile | the resulting profile; If omitted the function will write the profile to my_abstract_file_name. |
cmsHPROFILE lcm2CreateICCMatrixProfile2 | ( | float | gamma, |
float | rx, | ||
float | ry, | ||
float | gx, | ||
float | gy, | ||
float | bx, | ||
float | by, | ||
float | wx, | ||
float | wy | ||
) |
Create a profile from primaries, white point and one gamma value.
Function lcm2CreateICCMatrixProfile2
Used for ICC from EDID, Camera RAW etc. Marti calls these matrix/shaper.
Referenced by l2cmsCreateICCMatrixProfile().
cmsHPROFILE lcm2CreateProfileFragment | ( | const char * | in_space_profile, |
const char * | out_space_profile, | ||
double | icc_profile_version, | ||
const char * | my_abstract_description, | ||
const char * | provider, | ||
const char * | vendor, | ||
const char * | my_license, | ||
const char * | device_model, | ||
const char * | device_manufacturer, | ||
cmsHPROFILE | h_profile | ||
) |
Create a color profile starter.
Function lcm2CreateProfileFragment
In case both the in_space_profile and out_space_profile arguments are set to "*lab", the profile will be set to class abstract. In case the in_space_profile is not "*lab" and the later one is different, a color profile of class input will be generated. With in_space_profile not "*lab" and out_space_profile "*lab" a color profile of class output will be generated. Note such profiles have initially no backward LUT and can not be used for inverse color transforms, which might be a problem for general purpose ICC profiles. But you can add more tables if needed by passing in a previously created profile.
All profiles generated by this function are meant to be filled with colorimetric data by e.g. lcm2CreateProfileLutByFunc() or lcm2CreateICCMatrixProfile2().
Here a code example:
[in] | in_space_profile | input color space; for wildcards see lcm2OpenProfileFile() |
[in] | out_space_profile | output color space; for wildcards see lcm2OpenProfileFile() |
[in] | icc_profile_version | 2.3 or 4.3 |
[in] | my_abstract_description | internal profile name |
[in] | provider | e.g. "My Project 2016" |
[in] | vendor | e.g. "My Name" |
[in] | my_license | e.g. "This profile is made available by %s, with permission of %s, and may be copied, distributed, embedded, made, used, and sold without restriction. Altered versions of this profile shall have the original identification and copyright information removed and shall not be misrepresented as the original profile." first s is provider string arg and second s is filled by vendor string arg |
[in] | device_model | e.g. "My Set" |
[in] | device_manufacturer | e.g. "www.mydomain.net"; hint: lcms <= 2.08 writes a malformed desc tag |
[in,out] | h_profile | use existing profile; optional |
Referenced by lcm2CreateAbstractProfile().
int lcm2CreateProfileLutByFunc | ( | cmsHPROFILE | profile, |
lcm2Sampler_f | samplerMySpace, | ||
void * | samplerArg, | ||
const char * | in_space_profile, | ||
const char * | my_space_profile, | ||
const char * | out_space_profile, | ||
int | grid_size, | ||
cmsTagSignature | tag_sig | ||
) |
Generate a ICC profile LUT.
Function lcm2CreateProfileLutByFunc
This function takes a series of parameters and functions to create a ICC profile from. The sampler function operates in a input space and and creates colors in a output space. These values are filled into the profile LUT. It is possible to create effect profiles of class abstract or LUT profiles in any other color space including device links.
For some already available sampler funtions see Samplers.
[in,out] | profile | profile to add LUT table |
[in] | samplerMySpace | the function to fill the LUT with color |
[in] | samplerArg | data pointer to samplerMySpace |
[in] | my_space_profile | operating color space for samplerMySpace(); for wildcards see lcm2OpenProfileFile() |
[in] | in_space_profile | input color space for samplerMySpace(); for wildcards see lcm2OpenProfileFile() |
[in] | out_space_profile | output color space for samplerMySpace(); for wildcards see lcm2OpenProfileFile() |
[in] | grid_size | dimensions of the created LUT; e.g. 33 |
[in] | tag_sig | tag signature for the generated LUT; |
Referenced by lcm2CreateAbstractProfile().
int lcm2CreateProfileLutByFuncAndCurves | ( | cmsHPROFILE | profile, |
lcm2Sampler_f | samplerMySpace, | ||
void * | samplerArg, | ||
cmsToneCurve * | in_curves[], | ||
cmsToneCurve * | out_curves[], | ||
const char * | in_space_profile, | ||
const char * | my_space_profile, | ||
const char * | out_space_profile, | ||
int | grid_size, | ||
cmsTagSignature | tag_sig | ||
) |
Generate a ICC profile LUT.
Function lcm2CreateProfileLutByFuncAndCurves
This function takes a series of parameters and functions to create a ICC profile from. The sampler function operates in a input space and and creates colors in a output space. These values are filled into the profile LUT. It is possible to create effect profiles of class abstract or LUT profiles in any other color space including device links.
For some already available sampler funtions see Samplers.
[in,out] | profile | profile to add LUT table |
[in] | samplerMySpace | the function to fill the LUT with color |
[in] | samplerArg | data pointer to samplerMySpace |
[in] | in_curves | input curves |
[in] | out_curves | output curves |
[in] | my_space_profile | operating color space for samplerMySpace(); for wildcards see lcm2OpenProfileFile() |
[in] | in_space_profile | input color space for samplerMySpace(); for wildcards see lcm2OpenProfileFile() |
[in] | out_space_profile | output color space for samplerMySpace(); for wildcards see lcm2OpenProfileFile() |
[in] | grid_size | dimensions of the created LUT; e.g. 33 |
[in] | tag_sig | tag signature for the generated LUT; |
int lcm2MessageFunc | ( | int code | OY_UNUSED, |
const void *context_object | OY_UNUSED, | ||
const char * | format, | ||
... | |||
) |
default message function to console
Function lcm2MessageFunc
The default message function is used as a message printer to the console from library start.
code | a message code understood be your message handler or openiccMSG_e |
context_object | a openicc object is expected |
format | the text format string for following args |
... | the variable args fitting to format |
int lcm2MessageFuncSet | ( | lcm2Message_f | message_func | ) |
cmsHPROFILE lcm2OpenProfileFile | ( | const char * | my_space_profile, |
const char * | my_space_profile_path | ||
) |
Open a profile from file.
Function lcm2OpenProfileFile
[in] | my_space_profile | operating color space. Use a file name or possible wildcards:
|
[in] | my_space_profile_path | path name for for my_space_profile; optional |
int lcm2Version | ( | ) |
char* lcm2WriteProfileToFile | ( | cmsHPROFILE | my_space_profile, |
const char * | my_space_profile_name, | ||
const char * | my_space_profile_version, | ||
const char * | vendor_four_bytes | ||
) |
Write a profile to a file.
Function lcm2WriteProfileToFile
Suggested is a scheme of "space version vendor.icc".
[in] | my_space_profile | the profile |
[in] | my_space_profile_name | the color space name |
[in] | my_space_profile_version | the version of the profile; optional |
[in] | vendor_four_bytes | the vendor, just four bytes; optional |
void* lcm2WriteProfileToMem | ( | cmsHPROFILE * | profile, |
size_t * | size, | ||
void *(*)(size_t size) | allocateFunc | ||
) |
Function lcm2WriteProfileToMem
Save a cmsHPROFILE to a in memory data blob