Marti,
I extracted the code from our library, and removed nearly all calls besides the
ones to lcms2
What the code does now (because most of the useful code is gone), is to
- open the profile
- load the tag
- 'resize' the CLUT in the pipeline to 3 dimensions, 33 samples per dimension,
3 output channels
- save this tag again in the profile
- save the profile
I did not really try to compile this code, but these are indeed all the calls
made to lcms2
-------------- begin snippet ------------------------
FILE * loadFrom = gmg::fopen(_path, "rb");
cmsProfile profile = cmsOpenProfileFromStream(loadFrom, "r");
cmsPipeline * pipeline = reinterpret_cast< cmsPipeline *
>(cmsReadTag(profile, cmsSigAToB1Tag));
if (pipeline == NULL)
{
return false;
}
for (cmsStage* stage = cmsPipelineGetPtrToFirstStage(pipeline);
stage != NULL; stage = cmsPipelineGetPtrToFirstStage(pipeline))
{
cmsStageSignature stageSignature = cmsStageType(stage);
if (stageSignature == cmsSigCLutElemType)
{
// delete stage from pipe line
cmsPipelineUnlinkStage(_pipeline, cmsAT_BEGIN,
NULL);
// and create the one with the size we want
std::vector< cmsUInt32Number >
lcmsGranularity(3, 33);
stage =
cmsStageAllocCLut16bitGranular(contextID, &lcmsGranularity[0],
granularity.size(), 3, NULL);
}
else
{
// extract stage from pipe line
cmsPipelineUnlinkStage(_pipeline, cmsAT_BEGIN,
&stage);
}
cmsPipelineInsertStage(updatedPipeline, cmsAT_END,
stage);
}
cmsWriteTag(_profile.GetLCMS2Profile(),
lcms2::ProfileEditingSignatureToLCMSSignature(_signature), sizedpipeline);
// (over)writing the tag will also free the 'old' pipe line, so
we do not have to free the old
// pipeline. But .... writing the tag will also store only a
copy of our new pipeline, so we
// have to free our pipeline
cmsPipelineFree(sizedpipeline);
FILE * saveTo = gmg::fopen(savePath, "wb");
bool success = cmsSaveProfileToStream(cmsProfile, saveTo) ==
TRUE;
cmsCloseProfile(cmsProfile);
-------------- end snippet ------------------------
After running this kind of code on a profile with linked tags, the profile is
corrupt after write
Regards,
Frank
On 30 Jul 2012, at 16:14, Marti Maria wrote:
>
> Hi Frank,
>
> Do you mean you are trying to edit a profile which already have linked tags,
> and then you try to rewrite one of the copies?
>
> It may be a bug... Do you have code that illustrates the issue?
> Thanks,
> Marti
>
>
> -----Original Message-----
> From: Frank Vyncke [mailto:frank.vyn...@yin4yang.com]
> Sent: lunes, 30 de julio de 2012 14:50
> To: lcms-user@lists.sourceforge.net
> Subject: [Lcms-user] profile corrupt after update
>
> Hi,
>
> I am using lcms2 to update profile (pipe-lines) In general this works fine,
> but the profiles become corrupt when they have linked tags.
>
> steps:
> I open a profile that has linked tags for A2B1 and A2B2.
> I see in the internal structures that all data is correctly read, both tags
> shared the same pointer, offset etc, and A2B2 is marked as a link to A2B1 I
> then create a new pipeline, and call writetag on it to store in in A2B1
> (this appears the be the only way to update the CLUT data in a pipeline)
> however, when I follow the code in writetag, then I do not see any change to
> the A2B2 data. e.g. the offset and pointer are not reset, neither are they
> linked to the new data. I am not sure what the correct behavior would be,
> but something is wrong here.
> I can also not 'relink' with linktag because that one complains about the
> fact that the A2B2 tag already exists...
>
> Any idea?
>
> Frank
> ----------------------------------------------------------------------------
> --
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and threat
> landscape has changed and how IT managers can respond. Discussions will
> include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Lcms-user mailing list
> Lcms-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lcms-user
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user