PTErr_t makeOutputMatrixXform ( KpF15d16_p matrix, KpUInt32_t gridsize, fut_p FAR* theFut) { PTErr_t PTErr; ResponseRecord_t rTRC, gTRC, bTRC; ResponseRecord_p RR[3]; double row0[3], row1[3], row2[3]; double_p rowp[3]; MATRIXDATA mdata; KpInt32_t dim[3]; /* Initialize ResponseRecords to do nothing (identity mapping): */ rTRC.TagSig = gTRC.TagSig = bTRC.TagSig = CURVE_TYPE_SIG; rTRC.CurveCount = gTRC.CurveCount = bTRC.CurveCount = 0; RR[0] = &rTRC; /* set record pointers */ RR[1] = &gTRC; RR[2] = &bTRC; /* Form matrix (XYZ -> ABC): */ row0[0] = (double)matrix[0] / SCALEFIXED; row0[1] = (double)matrix[1] / SCALEFIXED; row0[2] = (double)matrix[2] / SCALEFIXED; row1[0] = (double)matrix[3] / SCALEFIXED; row1[1] = (double)matrix[4] / SCALEFIXED; row1[2] = (double)matrix[5] / SCALEFIXED; row2[0] = (double)matrix[6] / SCALEFIXED; row2[1] = (double)matrix[7] / SCALEFIXED; row2[2] = (double)matrix[8] / SCALEFIXED; rowp[0] = row0; /* set row pointers */ rowp[1] = row1; rowp[2] = row2; /* Construct matrix-data object: */ mdata.dim = 3; /* always! */ mdata.matrix = rowp; /* set pointers */ mdata.inResponse = RR; dim[0] = dim[1] = dim[2] = (KpInt32_t)gridsize; *theFut = fut_new_empty (3, dim, 3, KCP_XYZ_PCS, KCP_XYZ_PCS); if (*theFut == NULL) { return KCP_NO_MEMORY; } /* Make and return forward fut (XYZ -> ABC): */ PTErr = makeForwardXformFromMatrix (&mdata, KCP_TRC_LAGRANGE4_INTERP, dim, *theFut); return PTErr; }
PTErr_t PTNewMonoPT ( ResponseRecord_p grayTRC, KpUInt32_t gridsize, KpBool_t invert, PTRefNum_p thePTRefNumP) { PTErr_t PTErr; KpInt32_t dim[3], inSpace, outSpace; fut_p theFut = NULL; /* Check for valid ptrs */ PTErr = KCP_BAD_ARG; if (thePTRefNumP == NULL) goto GetOut; if (grayTRC == NULL) goto GetOut; if (gridsize < 2) goto GetOut; *thePTRefNumP = 0; /* all dimensions are the same */ dim[0] = dim[1] = dim[2] = (KpInt32_t) gridsize; /* pass the input arguments along to the fut maker */ if (invert == KPFALSE) { /* Create (1D -> 3D) FuT */ theFut = fut_new_empty (1, dim, 3, KCP_FIXED_RANGE, KCP_LAB_PCS); if (theFut == NULL) { goto ErrOut4; } PTErr = makeForwardXformMono (grayTRC, theFut); inSpace = KCM_MONO; /* setup the foward color space */ outSpace = KCM_CIE_LAB; } else { /* Create (3D -> 1D) FuT */ theFut = fut_new_empty (3, dim, 1, KCP_LAB_PCS, KCP_FIXED_RANGE); if (theFut == NULL) { goto ErrOut4; } PTErr = makeInverseXformMono (grayTRC, theFut); inSpace = KCM_CIE_LAB; /* setup the inverse color space */ outSpace = KCM_MONO; } if (PTErr != KCP_SUCCESS) { goto ErrOut1; } if (fut_to_mft (theFut) != 1) { /* convert to reference tables */ goto ErrOut3; } PTErr = fut2PT (&theFut, inSpace, outSpace, PTTYPE_CALCULATED, thePTRefNumP); /* make into PT */ if (PTErr != KCP_SUCCESS) { goto ErrOut0; } GetOut: return (PTErr); ErrOut4: PTErr = KCP_NO_MEMORY; goto ErrOut0; ErrOut3: PTErr = KCP_INCON_PT; goto ErrOut0; ErrOut1: PTErr = KCP_BAD_ARG; ErrOut0: if (theFut != NULL) fut_free (theFut); if (*thePTRefNumP != 0) PTCheckOut (*thePTRefNumP); goto GetOut; }