Quoting John Jefferies <john.jeffer...@globalgraphics.com>: > I want to know how many grid points are used in a clut tag. I've got > code to achieve that, but I've had to do some dodgy casts in the > process. The clut details are in _cmsStageCLutData from > lcms2_plugin.h (I'm not using a plugin though), but to use it I've > had to use _cmsStage_struct from lcms2_internal.h which isn't ideal. > Is there some better way of doing this or is it something that I'll > have to live with. I've included some simple code that I hope > illustrates the problem.
Hello John, What you see is a side effect of supporting the ICC V4 specification. In the old V2, Luts were quite easy to deal with, they could have some curves and the most rare cases a matrix, but you always had a CLUT with a fixed number of points. With V4, and more specially with the floating point additions, profile creators may use exotic combinations and you no longer can assume the CLUT has same number of nodes on each direction or that there is a CLUT at all. So, I'm afraid the part of your code that analyzes the pipeline is unavoidable, well it is unavoidable if you want to support V4, which is the case with lcms2. Then comes the issue with the internal header. You should not need this to read the number of nodes. _cmsStageCLutData is defined in the plug-in API, which is a sort of "I want to bypass the logic of the CMM and deal with profile internals" which is ok and exactly what you want to do. So, after you get a pointer to the CLUT stage, you could use cmsStageData() to get this data. One single cast to a struct defined in the plugin API and no internal functions. Instead of: stage_intern = (struct _cmsStage_struct *) stage; clut = (_cmsStageCLutData *) stage_intern->Data; you can use : clut = (_cmsStageCLutData *) cmsStageData(stage); Actually, this is a bug in the documentation as this function is not documented and it should. Thanks for pointing out. Best regards Marti > Many thanks. > > ------------ > #include "lcms2.h" > #include "lcms2_plugin.h" > > #include "lcms2_internal.h" > > void print_grid_points(void *p) { > unsigned int i; > void *pipeline; > cmsStage *stage; > struct _cmsStage_struct *stage_intern; > _cmsStageCLutData *clut; > > // 'p' contains a clut. > // We can easily find the clut stage of the A2B0 tag.. > pipeline = cmsReadTag(p, cmsSigAToB0Tag); > stage = cmsPipelineGetPtrToFirstStage(pipeline); > while (stage != NULL && cmsStageType(stage) != cmsSigCLutElemType) > stage = cmsStageNext(stage); > > // Accessing the clut details from lcms2_plugin.h requires > exposing a struct > // from lcms2_internal.h. > stage_intern = (struct _cmsStage_struct *) stage; > clut = (_cmsStageCLutData *) stage_intern->Data; > > // Print the grid points. > printf("Number of grid points ="); > for (i = 0; i < clut->Params->nInputs; i++) > printf(" %d,", clut->Params->nSamples[i]); > printf("\n"); > } > ------------ > > John ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Lcms-user mailing list Lcms-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lcms-user