Hello Marti,
I overlooked the fact that curveType uses uint16 values and not floats. So
I have to use cmsBuildTabulatedToneCurve16 instead of
cmsBuildTabulatedToneCurveFloat. The code below works now.
Thanks a lot for your help (and for LittleCMS in general).
Best regards,
Gert
cmsContext context = cmsCreateContext(0, 0);
cmsHPROFILE profile = cmsCreateProfilePlaceholder(context);
cmsSetProfileVersion(profile, 4.3);
cmsSetDeviceClass(profile, cmsSigDisplayClass);
cmsSetColorSpace(profile, cmsSigRgbData);
cmsSetPCS(profile, cmsSigXYZData);
cmsPipeline* pipeline = cmsPipelineAlloc(context, 3, 3);
cmsFloat64Number data[] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
cmsFloat64Number offset[] = {0.0, 0.0, 0.0};
cmsToneCurve* gamma[3];
gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma(context, 1.0);
cmsToneCurve *curves[3];
cmsUInt16Number rr[256];
cmsUInt16Number gg[256];
cmsUInt16Number bb[256];
for (int i = 0; i < 256; ++i)
{
rr[i] = gg[i] = bb[i] = round(double(i) / 255 * 65535);
}
curves[0] = cmsBuildTabulatedToneCurve16(context, 256, rr);
curves[1] = cmsBuildTabulatedToneCurve16(context, 256, gg);
curves[2] = cmsBuildTabulatedToneCurve16(context, 256, bb);
cmsPipelineInsertStage(pipeline, cmsAT_BEGIN,
cmsStageAllocToneCurves(context, 3, curves));
cmsPipelineInsertStage(pipeline, cmsAT_END,
cmsStageAllocMatrix(context, 3, 3, data, offset));
cmsPipelineInsertStage(pipeline, cmsAT_END,
cmsStageAllocToneCurves(context, 3, gamma));
cmsFreeToneCurve(gamma[0]);
cmsWriteTag(profile, cmsSigAToB0Tag, pipeline);
cmsPipelineFree(pipeline);
cmsSaveProfileToFile(profile, "test.icc");
cmsCloseProfile(profile);
2014-07-28 13:41 GMT+02:00 <marti.ma...@littlecms.com>:
>
>
> Hi,
>
> Littlecms allows to use arbitrary stages in pipelines, but the ICC spec
> restricts AToB tags to only certain pipelines and certain stages. In
> particular, floating point tabulated curves are not supported as part of
> AtoB tags. You need to read the ICC spec and use only the supported stages
> if you want to create ICC profiles.
>
>
> regards
> Marti
>
>
> Quoting Gert Van Hoey <gert.vanh...@gmail.com>:
>
> Hello,
>>
>> I’m having a problem adding a curveType to an AToB tag.
>>
>> The code below (based on an earlier post in this mailing list) produces a
>> profile with AToB tag containing parametric curves, as expected. But when
>> I try to add a curve specified as a list of values (by uncommenting the
>> commented line, and commenting the one just before), then no profile is
>> produced (cmsSaveProfileToFile returns false).
>>
>> Any suggestion about what’s going wrong ?
>>
>> Best regards,
>>
>> Gert
>>
>> cmsContext context = cmsCreateContext(0, 0);
>> cmsHPROFILE profile = cmsCreateProfilePlaceholder(context);
>> cmsSetProfileVersion(profile, 4.3);
>> cmsSetDeviceClass(profile, cmsSigDisplayClass);
>> cmsSetColorSpace(profile, cmsSigRgbData);
>> cmsSetPCS(profile, cmsSigXYZData);
>>
>> cmsPipeline* pipeline = cmsPipelineAlloc(context, 3, 3);
>> cmsFloat64Number data[] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
>> 1.0};
>> cmsFloat64Number offset[] = {0.0, 0.0, 0.0};
>> cmsToneCurve* gamma[3];
>> gamma[0] = gamma[1] = gamma[2] = cmsBuildGamma(context, 1.0);
>>
>> cmsToneCurve *curves[3];
>> cmsFloat32Number rr[256];
>> cmsFloat32Number gg[256];
>> cmsFloat32Number bb[256];
>> for (int i = 0; i < 256; ++i)
>> {
>> rr[i] = gg[i] = bb[i] = cmsFloat32Number(i) / 255;
>> }
>> curves[0] = cmsBuildTabulatedToneCurveFloat(context, 256, rr);
>> curves[1] = cmsBuildTabulatedToneCurveFloat(context, 256, gg);
>> curves[2] = cmsBuildTabulatedToneCurveFloat(context, 256, bb);
>>
>> cmsPipelineInsertStage(pipeline, cmsAT_BEGIN,
>> cmsStageAllocToneCurves(context, 3, gamma));
>> //cmsPipelineInsertStage(pipeline, cmsAT_BEGIN,
>> cmsStageAllocToneCurves(context, 3, curves));
>>
>> cmsPipelineInsertStage(pipeline, cmsAT_END,
>> cmsStageAllocMatrix(context, 3, 3, data, offset));
>> cmsPipelineInsertStage(pipeline, cmsAT_END,
>> cmsStageAllocToneCurves(context,
>> 3, gamma));
>> cmsFreeToneCurve(gamma[0]);
>> cmsWriteTag(profile, cmsSigAToB0Tag, pipeline);
>> cmsPipelineFree(pipeline);
>> cmsSaveProfileToFile(profile, "test.icc");
>> cmsCloseProfile(profile);
>>
>
>
>
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user