/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// This file is available under and governed by the GNU General Public
// License version 2 only, as published by the Free Software Foundation.
// However, the following notice accompanied the original version of this
// file:
//
//---------------------------------------------------------------------------------
//
// Little Color Management System
// Copyright (c) 1998-2011 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//---------------------------------------------------------------------------------
//
// This is the plug-in header file. Normal LittleCMS clients should not use it.
// It is provided for plug-in writters that may want to access the support
// functions to do low level operations. All plug-in related structures
// are defined here. Including this file forces to include the standard API too.
#ifndef _lcms_plugin_H
// Deal with Microsoft's attempt at deprecating C standard runtime functions
#ifdef _MSC_VER
# if (_MSC_VER >= 1400)
# ifndef _CRT_SECURE_NO_DEPRECATE
# define _CRT_SECURE_NO_DEPRECATE
# endif
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
# endif
#endif
#ifndef _lcms2_H
#include "lcms2.h"
#endif
// We need some standard C functions.
#include <stdlib.h>
#include <math.h>
#include <stdarg.h>
#include <memory.h>
#include <string.h>
#ifndef CMS_USE_CPP_API
# ifdef __cplusplus
extern "C" {
# endif
#endif
// Vector & Matrix operations -----------------------------------------------------------------------
#define VX 0
// Vectors
typedef struct {
cmsFloat64Number n[3];
} cmsVEC3;
// 3x3 Matrix
typedef struct {
cmsVEC3 v[3];
} cmsMAT3;
CMSAPI void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
// Error logging -------------------------------------------------------------------------------------
CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
// Memory management ----------------------------------------------------------------------------------
// I/O handler ----------------------------------------------------------------------------------
struct _cms_io_handler {
const void* Buffer);
};
// Endianess adjust functions
// Helper IO functions
CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array);
CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array);
// ICC base tag
typedef struct {
} _cmsTagBase;
// Type base helper functions
// Alignment functions
// To deal with text streams. 2K at most
// Fixed point helper functions
//----------------------------------------------------------------------------------------------------------
// Shared callbacks for user data
//----------------------------------------------------------------------------------------------------------
// Plug-in foundation
typedef struct _cmsPluginBaseStruct {
// Maximum number of types in a plugin array
//----------------------------------------------------------------------------------------------------------
// Memory handler. Each new plug-in type replaces current behaviour
typedef struct {
// Required
// Optional
// ------------------------------------------------------------------------------------------------------------------
// Interpolation. 16 bits and floating point versions.
struct _cms_interp_struc;
// Interpolation callbacks
// 16 bits forward interpolation. This function performs precision-limited linear interpolation
// and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
// choose to implement any other interpolation algorithm.
register cmsUInt16Number Output[],
register const struct _cms_interp_struc* p);
// Floating point forward interpolation. Full precision interpolation using floats. This is not a
// time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
// choose to implement any other interpolation algorithm.
const struct _cms_interp_struc* p);
// This type holds a pointer to an interpolator that can be either 16 bits or float
typedef union {
// Flags for interpolator selection
typedef struct _cms_interp_struc { // Used on all interpolations. Supplied by lcms2 when calling the interpolation function
cmsUInt32Number opta[MAX_INPUT_DIMENSIONS]; // Optimization for 3D CLUT. This is the number of nodes premultiplied for each
// dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular
// Samplings may vary according of the number of nodes for each dimension.
// Interpolators factory
typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
// The plug-in
typedef struct {
// Points to a user-supplied function which implements the factory
//----------------------------------------------------------------------------------------------------------
// Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10
// Evaluator callback for user-suplied parametric curves. May implement more than one type
typedef cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R);
// Plug-in may implement an arbitrary number of parametric curves
typedef struct {
//----------------------------------------------------------------------------------------------------------
// Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
// cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
// Formatter16 callback
struct _cmstransform_struct;
register cmsUInt16Number Values[],
register cmsUInt8Number* Buffer,
register cmsUInt32Number Stride);
// This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
typedef union {
} cmsFormatter;
typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
// Plug-in may implement an arbitrary number of formatters
typedef struct {
//----------------------------------------------------------------------------------------------------------
// Tag type handler. Each type is free to return anything it wants, and it is up to the caller to
// know in advance what is the type contained in the tag.
typedef struct _cms_typehandler_struct {
// Allocates and reads items
// Writes n Items
void* Ptr,
// Duplicate an item or array of items
const void *Ptr,
cmsUInt32Number n);
// Free all resources
void *Ptr);
// Additional parameters used by the calling thread
// Each plug-in implements a single type
typedef struct {
//----------------------------------------------------------------------------------------------------------
// This is the tag plugin, which identifies tags. For writing, a pointer to function is provided.
// This function should return the desired type for this tag, given the version of profile
// and the data being serialized.
typedef struct {
// For reading.
cmsUInt32Number nSupportedTypes; // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum)
// For writting
// Plug-in implements a single tag
typedef struct {
} cmsPluginTag;
//----------------------------------------------------------------------------------------------------------
// Custom intents. This function should join all profiles specified in the array in
// a single LUT. Any custom intent in the chain redirects to custom function. If more than
// one custom intent is found, the one located first is invoked. Usually users should use only one
// custom intent, so mixing custom intents in same multiprofile transform is not supported.
// Each plug-in defines a single intent number.
typedef struct {
//----------------------------------------------------------------------------------------------------------
// Pipelines, Multi Process Elements.
typedef void (* _cmsStageEvalFn) (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe);
// This function allocates a generic MPE
void* Data); // A generic pointer to whatever memory needed by the element
typedef struct {
// Data kept in "Element" member of cmsStage
// Curves
typedef struct {
// Matrix
typedef struct {
// CLUT
typedef struct {
union { // Can have only one of both representations at same time
cmsUInt16Number* T; // Points to the table 16 bits table
} Tab;
//----------------------------------------------------------------------------------------------------------
// Optimization. Using this plug-in, additional optimization strategies may be implemented.
// The function should return TRUE if any optimization is done on the LUT, this terminates
// the optimization search. Or FALSE if it is unable to optimize and want to give a chance
// to the rest of optimizers.
register cmsUInt16Number Out[],
register const void* Data);
// This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
// duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
void* PrivateData,
typedef struct {
// Optimize entry point
//----------------------------------------------------------------------------------------------------------
// Full xform
const void* InputBuffer,
void* OutputBuffer,
void** UserData,
cmsPipeline** Lut,
// Retrieve user data as specified by the factory
CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
// Retrieve formatters
CMSAPI void CMSEXPORT _cmsGetTransformFormatters16 (struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput);
CMSAPI void CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput);
typedef struct {
// Transform entry point
#ifndef CMS_USE_CPP_API
# ifdef __cplusplus
}
# endif
#endif
#define _lcms_plugin_H
#endif