author | Ted Gould <ted@gould.cx> | |
Sun, 29 Nov 2009 19:51:36 +0000 (13:51 -0600) | ||
committer | Ted Gould <ted@gould.cx> | |
Sun, 29 Nov 2009 19:51:36 +0000 (13:51 -0600) |
1 | 2 | |||
---|---|---|---|---|
src/color-profile.cpp | patch | | diff1 | | diff2 | | blob | history |
src/dropper-context.cpp | patch | | diff1 | | diff2 | | blob | history |
src/svg/svg-color.cpp | patch | | diff1 | | diff2 | | blob | history |
src/ui/dialog/document-properties.cpp | patch | | diff1 | | diff2 | | blob | history |
src/widgets/sp-color-icc-selector.cpp | patch | | diff1 | | diff2 | | blob | history |
diff --cc src/color-profile.cpp
index 5f236444975d7bdc2bc5e12457f35cef7c480df4,4b13073165b088e5b208e44e60c9b42ae6566bfb..310a37356fead70a3c521c44f8d599fed5533b7c
+++ b/src/color-profile.cpp
-
+ #ifdef HAVE_CONFIG_H
+ # include "config.h"
+ #endif
-//#define DEBUG_LCMS
+#define DEBUG_LCMS
#include <glib/gstdio.h>
#include <sys/fcntl.h>
#include <cstring>
#include <string>
+
+ #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 <windows.h>
+ #endif
+
#include "xml/repr.h"
+#include "color.h"
#include "color-profile.h"
#include "color-profile-fns.h"
#include "attributes.h"
diff --cc src/dropper-context.cpp
Simple merge
diff --cc src/svg/svg-color.cpp
index fcfbbdbd853723a88188a14a71d2e54482a57908,a8e24c311acfa4dfd099e4ff946e20ebec4b2e63..d6b33402faba8da0dd29e7ee00e73864b5ea8cd2
+++ b/src/svg/svg-color.cpp
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;i<count; i++){
+ color_in[i] = (guchar) ((((gdouble)icc->colors[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 c21f646291619477140f1f96c0f106a4733a8664,7e31b874a71969c1f434ab1128fb881b734c5c30..982fb341536b8e07b9d1abbd4129fc4fc0f283f9
_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 <color-profile> element in the XML)
// TODO remove use of 'active' desktop
diff --cc src/widgets/sp-color-icc-selector.cpp
Simple merge