From: Ted Gould Date: Sun, 29 Nov 2009 19:51:36 +0000 (-0600) Subject: Updating to current trunk X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8d7e67a03e5080d114e3e34c1a6c4377ce3291c0;p=inkscape.git Updating to current trunk --- 8d7e67a03e5080d114e3e34c1a6c4377ce3291c0 diff --cc src/color-profile.cpp index 5f2364449,4b1307316..310a37356 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@@ -1,6 -1,8 +1,8 @@@ - + #ifdef HAVE_CONFIG_H + # include "config.h" + #endif -//#define DEBUG_LCMS +#define DEBUG_LCMS #include #include @@@ -12,8 -14,15 +14,16 @@@ #include #include + + #ifdef WIN32 + #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. Required for correctly including icm.h + #define _WIN32_WINDOWS 0x0410 + #endif + #include + #endif + #include "xml/repr.h" +#include "color.h" #include "color-profile.h" #include "color-profile-fns.h" #include "attributes.h" diff --cc src/svg/svg-color.cpp index fcfbbdbd8,a8e24c311..d6b33402f --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@@ -463,40 -454,11 +463,45 @@@ sp_svg_create_color_hash( return colors; } +//helper function borrowed from src/widgets/sp-color-icc-selector.cpp: +void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies ); + +void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b){ + guchar color_out[4]; + guchar color_in[4]; + if (icc){ +g_message("profile name: %s", icc->colorProfile.c_str()); + Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(icc->colorProfile.c_str()); + if ( prof ) { + cmsHTRANSFORM trans = prof->getTransfToSRGB8(); + if ( trans ) { + gchar const** names = 0; + gchar const** tips = 0; + guint const* scales = 0; + getThings( prof->getColorSpace(), names, tips, scales ); + + guint count = _cmsChannelsOf( prof->getColorSpace() ); + if (count>4) count=4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?) + for (guint i=0;icolors[i])*256.0) * (gdouble)scales[i]); +g_message("input[%d]: %d",i, color_in[i]); + } + + cmsDoTransform( trans, color_in, color_out, 1 ); +g_message("transform to sRGB done"); + } + *r = color_out[0]; + *g = color_out[1]; + *b = color_out[2]; + } + } +} + + /* + * Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj + * Allowed ASCII first characters: ':', 'A'-'Z', '_', 'a'-'z' + * Allowed ASCII remaining chars add: '-', '.', '0'-'9', + */ bool sp_svg_read_icc_color( gchar const *str, gchar const **end_ptr, SVGICCColor* dest ) { bool good = true; diff --cc src/ui/dialog/document-properties.cpp index c21f64629,7e31b874a..982fb3415 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@@ -381,19 -381,40 +381,41 @@@ DocumentProperties::populate_available_ _menu.show_all(); } - //this is a quick workaround: - static gchar* sanitize_name(gchar* name){ - gchar* c=name; - while (*c != '\0'){ - if (*c == ' ') *c = '-'; - if (*c == '_') *c = '-'; - c++; + /** + * Cleans up name to remove disallowed characters. + * Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj + * Allowed ASCII first characters: ':', 'A'-'Z', '_', 'a'-'z' + * Allowed ASCII remaining chars add: '-', '.', '0'-'9', + * + * @param str the string to clean up. + */ + static void sanitizeName( Glib::ustring& str ) + { + if (str.size() > 1) { + char val = str.at(0); + if (((val < 'A') || (val > 'Z')) + && ((val < 'a') || (val > 'z')) + && (val != '_') + && (val != ':')) { + str.replace(0, 1, "-"); + } + for (Glib::ustring::size_type i = 1; i < str.size(); i++) { + char val = str.at(i); + if (((val < 'A') || (val > 'Z')) + && ((val < 'a') || (val > 'z')) + && ((val < '0') || (val > '9')) + && (val != '_') + && (val != ':') + && (val != '-') + && (val != '.')) { + str.replace(i, 1, "-"); + } + } } - return name; } -void DocumentProperties::linkSelectedProfile() +void +DocumentProperties::linkSelectedProfile() { //store this profile in the SVG document (create element in the XML) // TODO remove use of 'active' desktop