38
38
extern guint update_in_progress;
39
39
#define DEBUG_MESSAGE(key, ...) \
41
gint dump = prefs_get_int_attribute_limited("options.scislac", #key, 0, 0, 1);\
42
gint dumpD = prefs_get_int_attribute_limited("options.scislac", #key"D", 0, 0, 1);\
43
gint dumpD2 = prefs_get_int_attribute_limited("options.scislac", #key"D2", 0, 0, 1);\
41
Inkscape::Preferences *prefs = Inkscape::Preferences::get();\
42
bool dump = prefs->getBool(Glib::ustring("/options/scislac/") + #key);\
43
bool dumpD = prefs->getBool(Glib::ustring("/options/scislac/") + #key"D");\
44
bool dumpD2 = prefs->getBool(Glib::ustring("/options/scislac/") + #key"D2");\
44
45
dumpD &= ( (update_in_progress == 0) || dumpD2 );\
253
254
//# 1. Get complete URI of document
254
255
gchar const *docbase = SP_DOCUMENT_URI( doc );
257
g_warning("null docbase");
258
// Normal for files that have not yet been saved.
260
261
//g_message("docbase:%s\n", docbase);
261
262
org::w3c::dom::URI docUri(docbase);
262
263
//# 2. Get href of icc file. we don't care if it's rel or abs
264
265
//# 3. Resolve the href according the docBase. This follows
265
266
// the w3c specs. All absolute and relative issues are considered
266
267
org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri);
267
gchar* fullname = (gchar *)cprofUri.getNativePath().c_str();
268
gchar* fullname = g_strdup((gchar *)cprofUri.getNativePath().c_str());
268
269
cprof->_clearProfile();
269
270
cprof->profHandle = cmsOpenProfileFromFile( fullname, "r" );
270
271
if ( cprof->profHandle ) {
343
344
* Callback: write attributes to associated repr.
345
Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Node *repr, guint flags )
346
Inkscape::XML::Node* ColorProfile::write( SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags )
347
348
ColorProfile *cprof = COLORPROFILE(object);
349
350
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
350
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
351
351
repr = xml_doc->createElement("svg:color-profile");
370
370
if (cprof_parent_class->write) {
371
(* cprof_parent_class->write)(object, repr, flags);
371
(* cprof_parent_class->write)(object, xml_doc, repr, flags);
564
#endif // ENABLE_LCMS
565
static void findThings() {
566
std::list<gchar *> sources;
566
std::list<Glib::ustring> ColorProfile::getProfileDirs() {
567
std::list<Glib::ustring> sources;
568
569
gchar* base = profile_path("XXX");
584
585
sources.push_back(g_build_filename(dataDirs[i], "color", "icc", NULL));
587
while (!sources.empty()) {
588
gchar *dirname = sources.front();
589
if ( g_file_test( dirname, G_FILE_TEST_EXISTS ) && g_file_test( dirname, G_FILE_TEST_IS_DIR ) ) {
592
static void findThings() {
593
std::list<Glib::ustring> sources = ColorProfile::getProfileDirs();
595
for ( std::list<Glib::ustring>::const_iterator it = sources.begin(); it != sources.end(); ++it ) {
596
if ( g_file_test( it->c_str(), G_FILE_TEST_EXISTS ) && g_file_test( it->c_str(), G_FILE_TEST_IS_DIR ) ) {
591
GDir *dir = g_dir_open(dirname, 0, &err);
598
GDir *dir = g_dir_open(it->c_str(), 0, &err);
594
601
for (gchar const *file = g_dir_read_name(dir); file != NULL; file = g_dir_read_name(dir)) {
595
gchar *filepath = g_build_filename(dirname, file, NULL);
602
gchar *filepath = g_build_filename(it->c_str(), file, NULL);
598
605
if ( g_file_test( filepath, G_FILE_TEST_IS_DIR ) ) {
612
619
ssize_t got = read(fd, scratch, len);
613
620
if ( got != -1 ) {
614
621
size_t calcSize = (scratch[0] << 24) | (scratch[1] << 16) | (scratch[2] << 8) | scratch[3];
615
if ( calcSize > 128 && calcSize <= st.st_size ) {
622
if ( calcSize > 128 && calcSize <= static_cast<size_t>(st.st_size) ) {
616
623
isIccFile = (scratch[36] == 'a') && (scratch[37] == 'c') && (scratch[38] == 's') && (scratch[39] == 'p');
673
676
cmsHPROFILE Inkscape::colorprofile_get_system_profile_handle()
675
678
static cmsHPROFILE theOne = 0;
676
static std::string lastURI;
679
static Glib::ustring lastURI;
678
681
static bool init = false;
686
gchar const * uri = prefs_get_string_attribute("options.displayprofile", "uri");
689
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
690
Glib::ustring uri = prefs->getString("/options/displayprofile/uri");
689
if ( lastURI != std::string(uri) ) {
692
if ( !uri.empty() ) {
693
if ( uri != lastURI ) {
692
696
cmsCloseProfile( theOne );
695
699
cmsDeleteTransform( transf );
698
theOne = cmsOpenProfileFromFile( uri, "r" );
702
theOne = cmsOpenProfileFromFile( uri.data(), "r" );
700
704
// a display profile must have the proper stuff
701
705
icColorSpaceSignature space = cmsGetColorSpace(theOne);
731
735
cmsHPROFILE Inkscape::colorprofile_get_proof_profile_handle()
733
737
static cmsHPROFILE theOne = 0;
734
static std::string lastURI;
738
static Glib::ustring lastURI;
736
740
static bool init = false;
744
long long int which = prefs_get_int_attribute_limited( "options.softproof", "enable", 0, 0, 1 );
745
gchar const * uri = prefs_get_string_attribute("options.softproof", "uri");
748
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
749
bool which = prefs->getBool( "/options/softproof/enable");
750
Glib::ustring uri = prefs->getString("/options/softproof/uri");
747
if ( which && uri && *uri ) {
748
if ( lastURI != std::string(uri) ) {
752
if ( which && !uri.empty() ) {
753
if ( lastURI != uri ) {
751
756
cmsCloseProfile( theOne );
754
759
cmsDeleteTransform( transf );
757
theOne = cmsOpenProfileFromFile( uri, "r" );
762
theOne = cmsOpenProfileFromFile( uri.data(), "r" );
759
764
// a display profile must have the proper stuff
760
765
icColorSpaceSignature space = cmsGetColorSpace(theOne);
797
802
cmsHTRANSFORM Inkscape::colorprofile_get_display_transform()
799
long long int fromDisplay = prefs_get_int_attribute_limited( "options.displayprofile", "from_display", 0, 0, 1 );
804
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
805
bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
800
806
if ( fromDisplay ) {
802
808
cmsDeleteTransform(transf);
808
bool warn = prefs_get_int_attribute_limited( "options.softproof", "gamutwarn", 0, 0, 1 );
809
int intent = prefs_get_int_attribute_limited( "options.displayprofile", "intent", 0, 0, 3 );
810
int proofIntent = prefs_get_int_attribute_limited( "options.softproof", "intent", 0, 0, 3 );
811
bool bpc = prefs_get_int_attribute_limited( "options.softproof", "bpc", 0, 0, 1 );
814
bool warn = prefs->getBool( "/options/softproof/gamutwarn");
815
int intent = prefs->getIntLimited( "/options/displayprofile/intent", 0, 0, 3 );
816
int proofIntent = prefs->getIntLimited( "/options/softproof/intent", 0, 0, 3 );
817
bool bpc = prefs->getBool( "/options/softproof/bpc");
812
818
#if defined(cmsFLAGS_PRESERVEBLACK)
813
bool preserveBlack = prefs_get_int_attribute_limited( "options.softproof", "preserveblack", 0, 0, 1 );
819
bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack");
814
820
#endif //defined(cmsFLAGS_PRESERVEBLACK)
815
gchar const* colorStr = prefs_get_string_attribute("options.softproof", "gamutcolor");
816
Gdk::Color gamutColor( (colorStr && colorStr[0]) ? colorStr : "#808080");
821
Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
822
Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr );
818
824
if ( (warn != gamutWarn)
819
825
|| (lastIntent != intent)
854
860
dwFlags |= cmsFLAGS_PRESERVEBLACK;
856
862
#endif // defined(cmsFLAGS_PRESERVEBLACK)
857
transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGB_8, hprof, TYPE_RGB_8, proofProf, intent, proofIntent, dwFlags );
863
transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, hprof, TYPE_RGBA_8, proofProf, intent, proofIntent, dwFlags );
858
864
} else if ( hprof ) {
859
transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGB_8, hprof, TYPE_RGB_8, intent, 0 );
865
transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, hprof, TYPE_RGBA_8, intent, 0 );
943
949
if ( buf && bufLen ) {
945
if ( buf && bufLen ) {
946
digest.append(reinterpret_cast<unsigned char*>(buf), bufLen);
948
id = digest.finishHex();
950
id = Digest::hashHex(Digest::HASH_MD5,
951
reinterpret_cast<unsigned char*>(buf), bufLen);
950
953
// Note: if this is not a valid profile, item.hprof will be set to null.
951
954
item.hprof = cmsOpenProfileFromMem(buf, bufLen);
968
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
965
969
bool found = false;
966
970
for ( std::vector< std::vector<MemProfile> >::iterator it = perMonitorProfiles.begin(); it != perMonitorProfiles.end() && !found; ++it ) {
967
971
for ( std::vector<MemProfile>::iterator it2 = it->begin(); it2 != it->end() && !found; ++it2 ) {
968
972
if ( id == it2->id ) {
969
973
MemProfile& item = *it2;
971
bool warn = prefs_get_int_attribute_limited( "options.softproof", "gamutwarn", 0, 0, 1 );
972
int intent = prefs_get_int_attribute_limited( "options.displayprofile", "intent", 0, 0, 3 );
973
int proofIntent = prefs_get_int_attribute_limited( "options.softproof", "intent", 0, 0, 3 );
974
bool bpc = prefs_get_int_attribute_limited( "options.softproof", "bpc", 0, 0, 1 );
975
bool warn = prefs->getBool( "/options/softproof/gamutwarn");
976
int intent = prefs->getIntLimited( "/options/displayprofile/intent", 0, 0, 3 );
977
int proofIntent = prefs->getIntLimited( "/options/softproof/intent", 0, 0, 3 );
978
bool bpc = prefs->getBool( "/options/softproof/bpc");
975
979
#if defined(cmsFLAGS_PRESERVEBLACK)
976
bool preserveBlack = prefs_get_int_attribute_limited( "options.softproof", "preserveblack", 0, 0, 1 );
980
bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack");
977
981
#endif //defined(cmsFLAGS_PRESERVEBLACK)
978
gchar const* colorStr = prefs_get_string_attribute("options.softproof", "gamutcolor");
979
Gdk::Color gamutColor( (colorStr && colorStr[0]) ? colorStr : "#808080");
982
Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor");
983
Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr );
981
985
if ( (warn != gamutWarn)
982
986
|| (lastIntent != intent)
1016
1020
dwFlags |= cmsFLAGS_PRESERVEBLACK;
1018
1022
#endif // defined(cmsFLAGS_PRESERVEBLACK)
1019
item.transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGB_8, item.hprof, TYPE_RGB_8, proofProf, intent, proofIntent, dwFlags );
1023
item.transf = cmsCreateProofingTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, item.hprof, TYPE_RGBA_8, proofProf, intent, proofIntent, dwFlags );
1020
1024
} else if ( item.hprof ) {
1021
item.transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGB_8, item.hprof, TYPE_RGB_8, intent, 0 );
1025
item.transf = cmsCreateTransform( ColorProfile::getSRGBProfile(), TYPE_RGBA_8, item.hprof, TYPE_RGBA_8, intent, 0 );