summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-09-05 02:31:07 +0800
committerSebastian Rasmussen <sebras@gmail.com>2018-09-05 20:27:21 +0800
commit0296fd18b836fd70f57c0030054ba2131531ef06 (patch)
tree928096ac6059d9a9ad5b8f8b3be4e8864108896c
parent075fc6e3068e1a414de143d4b60c93618a75abab (diff)
downloadmupdf-0296fd18b836fd70f57c0030054ba2131531ef06.tar.xz
Take colorspace name from ICC profile.
-rw-r--r--source/fitz/color-lcms.c18
-rw-r--r--source/fitz/colorspace-imp.h1
-rw-r--r--source/fitz/colorspace.c7
3 files changed, 25 insertions, 1 deletions
diff --git a/source/fitz/color-lcms.c b/source/fitz/color-lcms.c
index 9efbb0b3..4dd231e9 100644
--- a/source/fitz/color-lcms.c
+++ b/source/fitz/color-lcms.c
@@ -71,6 +71,21 @@ fz_lcms_num_devcomps(cmsContext cmm_ctx, fz_iccprofile *profile)
return cmsChannelsOf(cmm_ctx, cmsGetColorSpace(cmm_ctx, profile->cmm_handle));
}
+static char *
+fz_lcms_description(cmsContext cmm_ctx, fz_iccprofile *profile)
+{
+ fz_context *ctx = (fz_context *)cmsGetContextUserData(cmm_ctx);
+ cmsMLU *descMLU;
+ char *desc;
+ size_t size;
+
+ descMLU = cmsReadTag(cmm_ctx, profile->cmm_handle, cmsSigProfileDescriptionTag);
+ size = cmsMLUgetASCII(cmm_ctx, descMLU, "en", "US", NULL, 0);
+ desc = fz_malloc(ctx, size);
+ cmsMLUgetASCII(cmm_ctx, descMLU, "en", "US", desc, size);
+ return desc;
+}
+
static void
fz_lcms_premultiply_row(fz_context *ctx, int n, int c, int w, unsigned char *s)
{
@@ -333,6 +348,7 @@ fz_lcms_init_profile(fz_cmm_instance *instance, fz_iccprofile *profile)
fz_throw(ctx, FZ_ERROR_GENERIC, "cmsOpenProfileFromMem failed");
}
profile->num_devcomp = fz_lcms_num_devcomps(cmm_ctx, profile);
+ profile->desc = fz_lcms_description(cmm_ctx, profile);
DEBUG_LCMS_MEM(("@@@@@@@ Create Profile End:: mupdf ctx = %p lcms ctx = %p profile = %p profile_cmm = %p \n", (void*)ctx, (void*)cmm_ctx, (void*)profile, (void*)profile->cmm_handle));
}
@@ -341,9 +357,11 @@ static void
fz_lcms_fin_profile(fz_cmm_instance *instance, fz_iccprofile *profile)
{
cmsContext cmm_ctx = (cmsContext)instance;
+ fz_context *ctx = (fz_context *)cmsGetContextUserData(cmm_ctx);
DEBUG_LCMS_MEM(("Free Profile:: profile = %p \n", (void*) profile->cmm_handle));
if (profile->cmm_handle != NULL)
cmsCloseProfile(cmm_ctx, profile->cmm_handle);
+ fz_free(ctx, profile->desc);
profile->cmm_handle = NULL;
}
diff --git a/source/fitz/colorspace-imp.h b/source/fitz/colorspace-imp.h
index 4664567f..fe052baf 100644
--- a/source/fitz/colorspace-imp.h
+++ b/source/fitz/colorspace-imp.h
@@ -41,6 +41,7 @@ struct fz_colorspace_s
struct fz_iccprofile_s
{
+ char *desc;
int num_devcomp;
int bgr;
fz_buffer *buffer;
diff --git a/source/fitz/colorspace.c b/source/fitz/colorspace.c
index 9cc178d9..701d1d92 100644
--- a/source/fitz/colorspace.c
+++ b/source/fitz/colorspace.c
@@ -3757,7 +3757,7 @@ fz_new_icc_colorspace(fz_context *ctx, enum fz_colorspace_type type, fz_buffer *
fz_colorspace *cs = NULL;
fz_iccprofile *profile;
int flags = FZ_COLORSPACE_IS_ICC;
- const char *name = colorspace_name_from_type(type);
+ const char *name;
int num;
profile = fz_malloc_struct(ctx, fz_iccprofile);
@@ -3806,6 +3806,11 @@ fz_new_icc_colorspace(fz_context *ctx, enum fz_colorspace_type type, fz_buffer *
fz_md5_icc(ctx, profile);
+ if (profile->desc)
+ name = profile->desc;
+ else
+ name = colorspace_name_from_type(type);
+
cs = fz_new_colorspace(ctx, name, type, flags, profile->num_devcomp,
NULL,
NULL,