color-profile.cpp revision 98bca1e5a1676e6bd459a85f0d54349d4a5df5ce
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
#include "inkscape.h"
#include "document.h"
#include "prefs-utils.h"
//#define DEBUG_LCMS
#ifdef DEBUG_LCMS
#include <gtk/gtkmessagedialog.h>
#endif // DEBUG_LCMS
using Inkscape::ColorProfile;
using Inkscape::ColorProfileClass;
namespace Inkscape
{
static void colorprofile_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr );
static Inkscape::XML::Node *colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags );
#if ENABLE_LCMS
#endif // ENABLE_LCMS
}
#ifdef DEBUG_LCMS
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
\
}\
if ( dumpD )\
{\
);\
dialog); \
}\
}
#endif // DEBUG_LCMS
static SPObject *cprof_parent_class;
/**
* Register ColorProfile class and return its type.
*/
{
if (!type) {
sizeof(ColorProfileClass),
sizeof(ColorProfile),
16,
NULL, /* value_table */
};
}
return type;
}
/**
* ColorProfile vtable initialization.
*/
{
}
/**
* Callback for ColorProfile object initialization.
*/
{
#if ENABLE_LCMS
cprof->profHandle = 0;
#endif // ENABLE_LCMS
}
/**
* Callback: free object
*/
{
// Unregister ourselves
if ( document ) {
}
}
}
}
}
#if ENABLE_LCMS
if ( cprof->profHandle ) {
cprof->profHandle = 0;
}
#endif // ENABLE_LCMS
}
/**
* Callback: set attributes from associated repr.
*/
static void Inkscape::colorprofile_build( SPObject *object, SPDocument *document, Inkscape::XML::Node *repr )
{
}
// Register
if ( document ) {
}
}
/**
* Callback: set attribute.
*/
{
switch (key) {
case SP_ATTR_XLINK_HREF:
}
if ( value ) {
#if ENABLE_LCMS
// TODO open filename and URIs properly
//FILE* fp = fopen_utf8name( filename, "r" );
//LCMSAPI cmsHPROFILE LCMSEXPORT cmsOpenProfileFromMem(LPVOID MemPtr, DWORD dwSize);
// Try to open relative
if (!doc) {
g_warning("object has no document. using active");
}
//# 1. Get complete URI of document
if (!docbase)
{
g_warning("null docbase");
docbase = "";
}
//g_message("docbase:%s\n", docbase);
//# 2. Get href of icc file. we don't care if it's rel or abs
//# 3. Resolve the href according the docBase. This follows
// the w3c specs. All absolute and relative issues are considered
#ifdef DEBUG_LCMS
DEBUG_MESSAGE( lcmsOne, "cmsOpenProfileFromFile( '%s'...) = %p", fullname, (void*)cprof->profHandle );
#endif // DEBUG_LCMS
#endif // ENABLE_LCMS
}
}
break;
case SP_ATTR_LOCAL:
}
break;
case SP_ATTR_NAME:
}
#ifdef DEBUG_LCMS
#endif // DEBUG_LCMS
break;
case SP_ATTR_RENDERING_INTENT:
}
if ( value ) {
} else {
}
} else {
}
break;
default:
}
break;
}
}
/**
* Callback: write attributes to associated repr.
*/
static Inkscape::XML::Node* Inkscape::colorprofile_write( SPObject *object, Inkscape::XML::Node *repr, guint flags )
{
}
}
}
}
}
}
return repr;
}
#if ENABLE_LCMS
{
if ( prof ) {
break;
}
}
}
}
return result;
}
cmsHPROFILE Inkscape::colorprofile_get_handle( SPDocument* document, guint* intent, gchar const* name )
{
cmsHPROFILE prof = 0;
if ( thing ) {
}
if ( intent ) {
}
#ifdef DEBUG_LCMS
DEBUG_MESSAGE( lcmsThree, "<color-profile> queried for profile of '%s'. Returning %p with intent of %d", name, prof, (intent? *intent:0) );
#endif // DEBUG_LCMS
return prof;
}
class ProfileInfo
{
public:
private:
};
{
}
{
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
}
}
return result;
}
{
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
}
}
return result;
}
{
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
break;
}
}
return result;
}
static void findThings() {
{
}
// first try user's local dir
sources.push_back( g_build_filename(base, ".color", "icc", NULL) ); // OpenICC recommends to deprecate this
for ( int i = 0; dataDirs[i]; i++ ) {
}
if (dir) {
} else {
bool isIccFile = false;
//0-3 == size
//36-39 == 'acsp' 0x61637370
if ( fd != -1 ) {
//size_t left = 40;
if ( got != -1 ) {
isIccFile = (scratch[36] == 'a') && (scratch[37] == 'c') && (scratch[38] == 's') && (scratch[39] == 'p');
}
}
}
}
if ( isIccFile ) {
if ( prof ) {
cmsCloseProfile( prof );
bool sameName = false;
for ( std::vector<ProfileInfo>::iterator it = knownProfiles.begin(); it != knownProfiles.end(); ++it ) {
sameName = true;
break;
}
}
if ( !sameName ) {
}
}
}
}
}
}
}
// toss the dirname
}
}
{
return 1;
}
static bool gamutWarn = false;
static bool lastBPC = false;
#if defined(cmsFLAGS_PRESERVEBLACK)
static bool lastPreserveBlack = false;
#endif // defined(cmsFLAGS_PRESERVEBLACK)
static int lastIntent = INTENT_PERCEPTUAL;
static int lastProofIntent = INTENT_PERCEPTUAL;
static cmsHTRANSFORM transf = 0;
static cmsHPROFILE srcprof = 0;
{
static cmsHPROFILE theOne = 0;
static bool init = false;
if ( !init ) {
findThings();
init = true;
}
long long int which = prefs_get_int_attribute_limited( "options.displayprofile", "enable", 0, 0, 1 );
if ( theOne ) {
}
if ( transf ) {
transf = 0;
}
if ( theOne ) {
// a display profile must have the proper stuff
if ( profClass != icSigDisplayClass ) {
g_warning("Not a display profile");
theOne = 0;
} else if ( space != icSigRgbData ) {
g_warning("Not an RGB profile");
theOne = 0;
} else {
}
}
}
} else if ( theOne ) {
theOne = 0;
if ( transf ) {
transf = 0;
}
}
return theOne;
}
{
static cmsHPROFILE theOne = 0;
static bool init = false;
if ( !init ) {
findThings();
init = true;
}
if ( theOne ) {
}
if ( transf ) {
transf = 0;
}
if ( theOne ) {
// a display profile must have the proper stuff
(void)space;
(void)profClass;
/*
if ( profClass != icSigDisplayClass ) {
g_warning("Not a display profile");
cmsCloseProfile( theOne );
theOne = 0;
} else if ( space != icSigRgbData ) {
g_warning("Not an RGB profile");
cmsCloseProfile( theOne );
theOne = 0;
} else {
*/
/*
}
*/
}
}
} else if ( theOne ) {
theOne = 0;
if ( transf ) {
transf = 0;
}
}
return theOne;
}
{
#if defined(cmsFLAGS_PRESERVEBLACK)
bool preserveBlack = prefs_get_int_attribute_limited( "options.softproof", "preserveblack", 0, 0, 1 );
#endif //defined(cmsFLAGS_PRESERVEBLACK)
|| (lastIntent != intent)
|| (lastProofIntent != proofIntent)
#if defined(cmsFLAGS_PRESERVEBLACK)
|| (preserveBlack != lastPreserveBlack)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
|| (gamutColor != lastGamutColor)
) {
if ( transf ) {
transf = 0;
}
lastIntent = intent;
#if defined(cmsFLAGS_PRESERVEBLACK)
#endif // defined(cmsFLAGS_PRESERVEBLACK)
}
// Fecth these now, as they might clear the transform as a side effect.
if ( !transf ) {
if ( !srcprof ) {
}
if ( gamutWarn ) {
cmsSetAlarmCodes(gamutColor.get_red() >> 8, gamutColor.get_green() >> 8, gamutColor.get_blue() >> 8);
}
if ( bpc ) {
}
#if defined(cmsFLAGS_PRESERVEBLACK)
if ( preserveBlack ) {
}
#endif // defined(cmsFLAGS_PRESERVEBLACK)
transf = cmsCreateProofingTransform( srcprof, TYPE_RGB_8, hprof, TYPE_RGB_8, proofProf, intent, proofIntent, dwFlags );
} else if ( hprof ) {
}
}
return transf;
}
#endif // ENABLE_LCMS
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :