tests/lcms_util: add SetTextTags()

This function sets some basic text tags to make an ICC file better
formed.

The code is taken from LittleCMS, https://github.com/mm2/Little-CMS.git
git revision
lcms2.13.1-28-g6ae2e99 (6ae2e99a3535417ca5c95b602eb61fdd29d294d0)
file src/cmsvirt.c.

Suggested-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
dev
Pekka Paalanen 2 years ago committed by Pekka Paalanen
parent 44c3079567
commit 5921a00b38
  1. 31
      tests/lcms_util.c
  2. 3
      tests/lcms_util.h

@ -1,5 +1,6 @@
/* /*
* Copyright 2022 Collabora, Ltd. * Copyright 2022 Collabora, Ltd.
* Copyright (c) 1998-2022 Marti Maria Saguer
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the
@ -198,3 +199,33 @@ build_MPE_curve_stage(cmsContext context_id, enum transfer_fn fn)
return stage; return stage;
} }
/* This function is taken from LittleCMS, pardon the odd style */
cmsBool
SetTextTags(cmsHPROFILE hProfile, const wchar_t* Description)
{
cmsMLU *DescriptionMLU, *CopyrightMLU;
cmsBool rc = FALSE;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
DescriptionMLU = cmsMLUalloc(ContextID, 1);
CopyrightMLU = cmsMLUalloc(ContextID, 1);
if (DescriptionMLU == NULL || CopyrightMLU == NULL) goto Error;
if (!cmsMLUsetWide(DescriptionMLU, "en", "US", Description)) goto Error;
if (!cmsMLUsetWide(CopyrightMLU, "en", "US", L"No copyright, use freely")) goto Error;
if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag, DescriptionMLU)) goto Error;
if (!cmsWriteTag(hProfile, cmsSigCopyrightTag, CopyrightMLU)) goto Error;
rc = TRUE;
Error:
if (DescriptionMLU)
cmsMLUfree(DescriptionMLU);
if (CopyrightMLU)
cmsMLUfree(CopyrightMLU);
return rc;
}

@ -34,3 +34,6 @@ build_MPE_curve(cmsContext ctx, enum transfer_fn fn);
cmsStage * cmsStage *
build_MPE_curve_stage(cmsContext context_id, enum transfer_fn fn); build_MPE_curve_stage(cmsContext context_id, enum transfer_fn fn);
cmsBool
SetTextTags(cmsHPROFILE hProfile, const wchar_t* Description);

Loading…
Cancel
Save