diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index 19b9b19a79c0fe587f7988a5a574ac23c0421035..f9915031bb0cfdf37766efaf791a1bc9d0b6497e 100644 (file)
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
#include "io/sys.h"
#include <png.h>
-
+#if ENABLE_LCMS
+#include "color-profile-fns.h"
+#endif // ENABLE_LCMS
/*
* SPImage
*/
}
else
{
- g_warning ("unable to open file: %s", filename);
+ g_warning ("Unable to open linked file: %s", filename);
}
/*
@@ -478,6 +480,7 @@ sp_image_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
sp_object_read_attr (object, "width");
sp_object_read_attr (object, "height");
sp_object_read_attr (object, "preserveAspectRatio");
+ sp_object_read_attr (object, "color-profile");
/* Register */
sp_document_add_resource (document, "image", object);
image->pixbuf = NULL;
}
+#if ENABLE_LCMS
+ if (image->color_profile) {
+ g_free (image->color_profile);
+ image->color_profile = NULL;
+ }
+#endif ENABLE_LCMS
+
if (((SPObjectClass *) parent_class)->release)
((SPObjectClass *) parent_class)->release (object);
}
image->aspect_clip = clip;
}
break;
+#if ENABLE_LCMS
+ case SP_PROP_COLOR_PROFILE:
+ if ( image->color_profile ) {
+ g_free (image->color_profile);
+ }
+ image->color_profile = (value) ? g_strdup (value) : NULL;
+ // TODO check on this HREF_MODIFIED flag
+ object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_IMAGE_HREF_MODIFIED_FLAG);
+ break;
+#endif // ENABLE_LCMS
default:
if (((SPObjectClass *) (parent_class))->set)
((SPObjectClass *) (parent_class))->set (object, key, value);
pixbuf = sp_image_repr_read_image (object->repr);
if (pixbuf) {
pixbuf = sp_image_pixbuf_force_rgba (pixbuf);
+// BLIP
+#if ENABLE_LCMS
+ if ( image->color_profile )
+ {
+ int imagewidth = gdk_pixbuf_get_width( pixbuf );
+ int imageheight = gdk_pixbuf_get_height( pixbuf );
+ int rowstride = gdk_pixbuf_get_rowstride( pixbuf );
+ guchar* px = gdk_pixbuf_get_pixels( pixbuf );
+
+ if ( px ) {
+ cmsHPROFILE prof = Inkscape::colorprofile_get_handle( SP_OBJECT_DOCUMENT( object ), image->color_profile );
+ if ( prof ) {
+ icProfileClassSignature profileClass = cmsGetDeviceClass( prof );
+ if ( profileClass != icSigNamedColorClass ) {
+ cmsHPROFILE destProf = cmsCreate_sRGBProfile();
+ cmsHTRANSFORM transf = cmsCreateTransform( prof,
+ TYPE_RGBA_8,
+ destProf,
+ TYPE_RGBA_8,
+ INTENT_PERCEPTUAL, 0 );
+ if ( transf ) {
+ guchar* currLine = px;
+ for ( int y = 0; y < imageheight; y++ ) {
+ // Since the types are the same size, we can do the transformation in-place
+ cmsDoTransform( transf, currLine, currLine, imagewidth );
+ currLine += rowstride;
+ }
+
+ cmsDeleteTransform( transf );
+ }
+ cmsCloseProfile( destProf );
+ }
+ }
+ }
+ }
+#endif // ENABLE_LCMS
image->pixbuf = pixbuf;
}
}
if (image->width._set) sp_repr_set_svg_double(repr, "width", image->width.computed);
if (image->height._set) sp_repr_set_svg_double(repr, "height", image->height.computed);
repr->setAttribute("preserveAspectRatio", object->repr->attribute("preserveAspectRatio"));
+#if ENABLE_LCMS
+ if (image->color_profile) repr->setAttribute("color-profile", image->color_profile);
+#endif // ENABLE_LCMS
if (((SPObjectClass *) (parent_class))->write)
((SPObjectClass *) (parent_class))->write (object, repr, flags);
SPImage *image = SP_IMAGE(item);
char *href_desc;
if (image->href) {
- href_desc = (strncmp(image->href, "data:", 5) == 0)
+ href_desc = (strncmp(image->href, "data:", 5) == 0)
? g_strdup(_("embedded"))
: xml_quote_strdup(image->href);
} else {
g_warning("Attempting to call strncmp() with a null pointer.");
href_desc = g_strdup(_("(null_pointer)")); // we call g_free() on href_desc
- }
+ }
char *ret = ( image->pixbuf == NULL
? g_strdup_printf(_("<b>Image with bad reference</b>: %s"), href_desc)