Commit 0eaed698 authored by Paolo Bacchilega's avatar Paolo Bacchilega

jpeg reader: use the sRGB profile if the ColorSpace tag is set to sRGB

parent d06b6d8e
...@@ -200,7 +200,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream, ...@@ -200,7 +200,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
_jpeg_info_data_init (&jpeg_info); _jpeg_info_data_init (&jpeg_info);
info_flags = _JPEG_INFO_EXIF_ORIENTATION; info_flags = _JPEG_INFO_EXIF_ORIENTATION;
#if HAVE_LCMS2 #if HAVE_LCMS2
info_flags |= _JPEG_INFO_ICC_PROFILE; info_flags |= _JPEG_INFO_EXIF_COLOR_SPACE | _JPEG_INFO_ICC_PROFILE;
#endif #endif
_jpeg_info_get_from_buffer (in_buffer, in_buffer_size, info_flags, &jpeg_info); _jpeg_info_get_from_buffer (in_buffer, in_buffer_size, info_flags, &jpeg_info);
if (jpeg_info.valid & _JPEG_INFO_EXIF_ORIENTATION) if (jpeg_info.valid & _JPEG_INFO_EXIF_ORIENTATION)
...@@ -208,10 +208,21 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream, ...@@ -208,10 +208,21 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
else else
orientation = GTH_TRANSFORM_NONE; orientation = GTH_TRANSFORM_NONE;
#if HAVE_LCMS2 #if HAVE_LCMS2
if (jpeg_info.valid & _JPEG_INFO_ICC_PROFILE) { {
GthICCProfile *profile = gth_icc_profile_new (GTH_ICC_PROFILE_ID_UNKNOWN, cmsOpenProfileFromMem (jpeg_info.icc_data, jpeg_info.icc_data_size)); GthICCProfile *profile = NULL;
gth_image_set_icc_profile (image, profile);
g_object_unref (profile); if (jpeg_info.valid & _JPEG_INFO_ICC_PROFILE) {
profile = gth_icc_profile_new (GTH_ICC_PROFILE_ID_UNKNOWN, cmsOpenProfileFromMem (jpeg_info.icc_data, jpeg_info.icc_data_size));
}
else if (jpeg_info.valid & _JPEG_INFO_EXIF_COLOR_SPACE) {
if (jpeg_info.color_space == GTH_COLOR_SPACE_SRGB)
profile = gth_icc_profile_new_srgb ();
}
if (profile != NULL) {
gth_image_set_icc_profile (image, profile);
g_object_unref (profile);
}
} }
#endif #endif
_jpeg_info_data_dispose (&jpeg_info); _jpeg_info_data_dispose (&jpeg_info);
......
...@@ -169,6 +169,31 @@ gth_icc_profile_new (const char *id, ...@@ -169,6 +169,31 @@ gth_icc_profile_new (const char *id,
} }
GthICCProfile *
gth_icc_profile_new_srgb (void)
{
#ifdef HAVE_LCMS2
char *id;
GthCMSProfile cmd_profile;
GthICCProfile *icc_profile;
id = g_strdup ("standard://srgb");
cmd_profile = (GthCMSProfile) cmsCreate_sRGBProfile ();
icc_profile = gth_icc_profile_new (id, cmd_profile);
g_free (id);
return icc_profile;
#else
return NULL;
#endif
}
const char * const char *
gth_icc_profile_get_id (GthICCProfile *self) gth_icc_profile_get_id (GthICCProfile *self)
{ {
......
...@@ -79,6 +79,7 @@ void gth_cms_transform_free (GthCMSTransform transform); ...@@ -79,6 +79,7 @@ void gth_cms_transform_free (GthCMSTransform transform);
GType gth_icc_profile_get_type (void); GType gth_icc_profile_get_type (void);
GthICCProfile * gth_icc_profile_new (const char *id, GthICCProfile * gth_icc_profile_new (const char *id,
GthCMSProfile profile); GthCMSProfile profile);
GthICCProfile * gth_icc_profile_new_srgb (void);
const char * gth_icc_profile_get_id (GthICCProfile *icc_profile); const char * gth_icc_profile_get_id (GthICCProfile *icc_profile);
gboolean gth_icc_profile_id_is_unknown (const char *id); gboolean gth_icc_profile_id_is_unknown (const char *id);
GthCMSProfile gth_icc_profile_get_profile (GthICCProfile *icc_profile); GthCMSProfile gth_icc_profile_get_profile (GthICCProfile *icc_profile);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment