/* ---------------------------------------------------------------------- */ SpStatus_t TransformPels ( PTRefNum_t pt, KpUInt8_t FAR *Pels, int nPels) { /* * Transform the pel array using the pt * The array is assumes to be in plane-sequential order */ PTEvalPB_t dtpb; PTCompDef_t comps [3]; opRefNum_t opRefNum; int i; PTErr_t pterr; for (i = 0; i < 3; i++) { comps [i].pelStride = 3 * sizeof(*Pels); comps [i].lineStride = nPels * 3 * sizeof (*Pels); comps [i].addr = (void FAR *) (Pels+i); } dtpb.nPels = nPels; dtpb.nLines = 1; dtpb.nOutputs = dtpb.nInputs = 3; dtpb.output = dtpb.input = comps; pterr = PTEval (pt, &dtpb, KCP_EVAL_DEFAULT, 0, 1, &opRefNum, NULL); return (SpStatusFromPTErr(pterr)); }
/*-------------------------------------------------------------------- * DESCRIPTION * Create a duplicate of an existing transform. * * AUTHOR * gbp * * DATE Modified * 25 Jan 99 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpXformDuplicate ( SpXform_t srcXform, SpXform_t FAR *dupXform) { SpStatus_t Status; PTRefNum_t srcRefNum, dupRefNum; PTErr_t PTStat; *dupXform = NULL; /* Get the PTRefNum for the transform */ Status = SpXformGetRefNum (srcXform, &srcRefNum); if (SpStatSuccess != Status) { return Status; } /* duplicate it by using PTCombine */ PTStat = PTCombine (0, srcRefNum, NULL, &dupRefNum); if (KCP_SUCCESS != PTStat) { return (SpStatusFromPTErr(PTStat)); } /* build an SpXform_t from the RefNum */ if (SpStatSuccess == Status) Status = SpXformFromPTRefNumImp (dupRefNum, dupXform); /* free PT if SpXform_t not created */ if (SpStatSuccess != Status) PTCheckOut (dupRefNum); #if defined KCP_DIAG_LOG {KpChar_t string[256]; sprintf (string, "\nSpXformFromBufferDT\n *dupXform %x\n",*dupXform); kcpDiagLog (string); } #endif return Status; }
/*--------------------------------------------------------------------- DESCRIPTION This function transforms a pel array (in place) using a pt The array is assumed to be in plane-sequential order The data type is assumed to be 12-bit (KCM_USHORT_12) INPUTS PTRefNum_t pt --- reference # of the pt to be transformed KpUInt16_t FAR *Pels --- pointer to the data int nPels --- number of pixels in data stream OUTPUTS KpUInt16_t FAR *Pels --- pointer to data that has been xformed RETURNS SpStatus_t - SpStatSuccess if successful, otherwise an sprofile error AUTHOR mtobin -------------------------------------------------------------------------*/ SpStatus_t Transform12BPels ( PTRefNum_t pt, KpUInt16_t FAR *Pels, int nPels) { opRefNum_t opRefNum; PTEvalDTPB_t dtpb; PTErr_t PTStat; KpInt32_t i; PTCompDef_t comps [3]; SpStatus_t Status; for (i = 0; i < 3; i++) { comps [i].pelStride = 3 * sizeof(*Pels); comps [i].lineStride = nPels * 3 * sizeof (*Pels); comps [i].addr = (void FAR *) (Pels+i); } /* build color processor image structure */ dtpb.nPels = nPels; dtpb.nLines = 1; dtpb.nInputs = 3; dtpb.input = comps; dtpb.dataTypeI = KCM_USHORT_12; dtpb.nOutputs = 3; dtpb.output = comps; /* evaluate in place */ dtpb.dataTypeO = KCM_USHORT_12; /* do the transformation */ PTStat = PTEvalDT (pt, &dtpb, KCP_EVAL_DEFAULT, 0, 1, &opRefNum, NULL); /* translate the return value to an Sp error */ Status = SpStatusFromPTErr(PTStat); return Status; }
/*-------------------------------------------------------------------- * DESCRIPTION * Construct Xform given a PT reference number. No RCS -> LAB color * space conversion is performed. * * AUTHOR * mjb * * DATE CREATED * September 27, 1995 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpXformFromPTRefNumNC ( PTRefNum_t FAR *RefNum, SpXform_t FAR *Xform) { KpInt32_t SpaceIn, SpaceOut; KpInt32_t SenseIn, SenseOut; KpInt32_t Class; int Index; SpStatus_t Status; PTErr_t InvertStat; Class = SpGetKcmAttrInt (*RefNum, KCM_CLASS); SpaceIn = SpGetKcmAttrInt (*RefNum, KCM_SPACE_IN); SpaceOut = SpGetKcmAttrInt (*RefNum, KCM_SPACE_OUT); SenseIn = SpGetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_IN); SenseOut = SpGetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_OUT); Index = 0; Status = SpStatSuccess; /* Invert input, if negative */ if ((KCM_RCS != SpaceIn) && (KCM_NEGATIVE == SenseIn)) { InvertStat = PTInvert (*RefNum, KCM_MEDIUM_SENSE_IN); if (InvertStat != KCP_SUCCESS) { PTCheckOut (*RefNum); *RefNum = 0; return SpStatusFromPTErr(InvertStat); } Status = SpSetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_IN, KCM_POSITIVE); if (SpStatSuccess != Status) { PTCheckOut (*RefNum); *RefNum = 0; return Status; } } /* Invert output, if negative */ if ((KCM_RCS != SpaceOut) && (KCM_NEGATIVE == SenseOut)) { InvertStat = PTInvert (*RefNum, KCM_MEDIUM_SENSE_OUT); if (InvertStat != KCP_SUCCESS) { PTCheckOut (*RefNum); return SpStatusFromPTErr(InvertStat); } Status = SpSetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_OUT, KCM_POSITIVE); if (SpStatSuccess != Status) { PTCheckOut (*RefNum); *RefNum = 0; return Status; } } Status = SpSetKcmAttrInt (*RefNum, KCM_CLASS, Class); if (SpStatSuccess != Status) { PTCheckOut (*RefNum); *RefNum = 0; return Status; } Status = SpXformFromPTRefNumImp (*RefNum, Xform); *RefNum = 0; return Status; }
/*-------------------------------------------------------------------- * DESCRIPTION * Construct Xform given a PT reference number. * FOR PT2PF building ONLY !! * * AUTHOR * lcc * * DATE CREATED * February 9, 1995 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpXformFromPTRefNumCombine ( SpConnectType_t ConnectType, SpParadigm_t ParadigmType, PTRefNum_t FAR *RefNum, SpXform_t FAR *Xform) { KpInt32_t SpaceIn, SpaceOut; KpInt32_t SenseIn, SenseOut; KpInt32_t Class, Render; int Index; KpInt32_t FailXform; SpStatus_t Status; PTRefNum_t CvrtInRefNum, CvrtOutRefNum; PTRefNum_t RefNumList [3]; PTRefNum_t NewRefNum; PTErr_t InvertStat; Class = SpGetKcmAttrInt (*RefNum, KCM_CLASS); SpaceIn = SpGetKcmAttrInt (*RefNum, KCM_SPACE_IN); SpaceOut = SpGetKcmAttrInt (*RefNum, KCM_SPACE_OUT); SenseIn = SpGetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_IN); SenseOut = SpGetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_OUT); /* setup to fix color spaces */ Index = 0; Status = SpStatSuccess; KpEnterCriticalSection (&SpCacheCritFlag); /* setup to fix input color space */ if (KCM_RCS == SpaceIn) { Render = SpGetKcmAttrInt (*RefNum, KCM_COMPRESSION_OUT); if (Render == KCM_UNKNOWN) Render = KCM_PERCEPTUAL; Status = SpXformBuildCnvrt (KPTRUE, Render, ConnectType, ParadigmType, &CvrtInRefNum); if (SpStatSuccess == Status) { RefNumList [Index++] = CvrtInRefNum; RefNumList [Index++] = *RefNum; } } else RefNumList [Index++] = *RefNum; /* setup to fix output color space */ if (KCM_RCS == SpaceOut) { Render = KCM_PERCEPTUAL; if (SpStatSuccess == Status) Status = SpXformBuildCnvrt (KPFALSE, Render, ConnectType, ParadigmType, &CvrtOutRefNum); if (SpStatSuccess == Status) RefNumList [Index++] = CvrtOutRefNum; } /* fix the color spaces */ if ((SpStatSuccess == Status) && (1 != Index)) { Status = SpConnectSequenceCombine (ConnectType, Index, RefNumList, &NewRefNum, &FailXform, NULL, NULL); PTCheckOut (*RefNum); *RefNum = NewRefNum; } KpLeaveCriticalSection (&SpCacheCritFlag); if (SpStatSuccess != Status) return Status; /* Invert input, if negative */ if ((KCM_RCS != SpaceIn) && (KCM_NEGATIVE == SenseIn)) { InvertStat = PTInvert (*RefNum, KCM_MEDIUM_SENSE_IN); if (InvertStat != KCP_SUCCESS) { PTCheckOut (*RefNum); return SpStatusFromPTErr(InvertStat); } Status = SpSetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_IN, KCM_POSITIVE); if (SpStatSuccess != Status) { PTCheckOut (*RefNum); return Status; } } /* Invert output, if negative */ if ((KCM_RCS != SpaceOut) && (KCM_NEGATIVE == SenseOut)) { InvertStat = PTInvert (*RefNum, KCM_MEDIUM_SENSE_OUT); if (InvertStat != KCP_SUCCESS) { PTCheckOut (*RefNum); return SpStatusFromPTErr(InvertStat); } Status = SpSetKcmAttrInt (*RefNum, KCM_MEDIUM_SENSE_OUT, KCM_POSITIVE); if (SpStatSuccess != Status) { PTCheckOut (*RefNum); return Status; } } Status = SpSetKcmAttrInt (*RefNum, KCM_CLASS, Class); Status = SpXformFromPTRefNumImp (*RefNum, Xform); *RefNum = 0; return Status; }
/*************************************************************************** * FUNCTION NAME * SpXformInvert * * DESCRIPTION * This function inverts the transform specified by Xform. If invertInp * is true the input tables are inverted and if invertOut is true then * the output tables are inverted. * * This function should be in the profile processor. It was added here * temporarily because the profile processor code was frozen at the time * this function was created. * ***************************************************************************/ SpStatus_t KSPAPI SpXformInvert ( SpXform_t Xform, KpBool_t invertInp, KpBool_t invertOut) { PTRefNum_t refNum; PTErr_t ok; SpStatus_t spStatus; /* Get the PTRefNum for the transform */ spStatus = SpXformGetRefNum (Xform, &refNum); if (SpStatSuccess != spStatus) { return spStatus; } /* Invert the input tables */ if (invertInp) { /* Set the KCM_MEDIUM_SENSE_IN attribute to KCM_POSITIVE, and the KCM_SENSE_INVERTIBLE_IN attribute to KCM_IS_INVERTIBLE */ spStatus = SpSetKcmAttrInt (refNum, KCM_SENSE_INVERTIBLE_IN, KCM_IS_INVERTIBLE); if (SpStatSuccess != spStatus) { return spStatus; } spStatus = SpSetKcmAttrInt (refNum, KCM_MEDIUM_SENSE_IN, KCM_POSITIVE); if (SpStatSuccess != spStatus) { return spStatus; } ok = PTInvert (refNum, KCM_MEDIUM_SENSE_IN); if (ok != KCP_SUCCESS) { return SpStatusFromPTErr(ok); } } /* Invert the output tables */ if (invertOut) { /* Set the KCM_MEDIUM_SENSE_OUT attribute to KCM_POSITIVE, and the KCM_SENSE_INVERTIBLE_OUT attribute to KCM_IS_INVERTIBLE */ spStatus = SpSetKcmAttrInt (refNum, KCM_SENSE_INVERTIBLE_OUT, KCM_IS_INVERTIBLE); if (SpStatSuccess != spStatus) { return spStatus; } spStatus = SpSetKcmAttrInt (refNum, KCM_MEDIUM_SENSE_OUT, KCM_POSITIVE); if (SpStatSuccess != spStatus) { return spStatus; } ok = PTInvert (refNum, KCM_MEDIUM_SENSE_OUT); if (ok != KCP_SUCCESS) { return SpStatusFromPTErr(ok); } } return SpStatSuccess; }
SpStatus_t KSPAPI SpXformGetBufferSizeDT(SpXform_t spXform, KpUInt32_t LutType, KpInt32_t SpDataType, KpUInt32_t *Datasize) { PTRefNum_t refNum; SpStatus_t spStatus; PTErr_t PTStat; KpUInt32_t MFType; KpInt32_t KcmDataType; spStatus = SpDTtoKcmDT (SpDataType, &KcmDataType); if (spStatus != SpStatSuccess) { return (spStatus); } /* Get the Color Processor PTRefNum of the SpXform */ spStatus = SpXformGetRefNum (spXform, &refNum); if (SpStatSuccess != spStatus) return spStatus; /* determine type of transform to get */ switch (LutType) { case SP_ICC_FUT: MFType = PTTYPE_FUTF; break; case SP_ICC_MFT1: MFType = PTTYPE_MFT1; break; case SP_ICC_MFT2: if (KcmDataType == KCM_ICC_TYPE_0) MFType = PTTYPE_MFT2_VER_0; else MFType = PTTYPE_MFT2; break; case SP_ICC_MAB1: MFType = PTTYPE_MAB1; break; case SP_ICC_MAB2: MFType = PTTYPE_MAB2; break; case SP_ICC_MBA1: MFType = PTTYPE_MBA1; break; case SP_ICC_MBA2: MFType = PTTYPE_MBA2; break; default: return SpStatOutOfRange; } PTStat = PTGetSizeF (refNum, MFType, (KpInt32_t FAR *) Datasize); return SpStatusFromPTErr(PTStat); }
/*************************************************************************** * FUNCTION NAME * SpXformBufferDT * * DESCRIPTION * This function copies the PT associated with the PTRefNum in * the Xform to the Address given. It will be in the format * requested by the caller. The SpXform is NOT freed by this * function. * * ***************************************************************************/ SpStatus_t KSPAPI SpXformToBufferDT(SpXform_t spXform, KpUInt32_t LutType, KpInt32_t SpDataType, KpUInt32_t Datasize, SpHugeBuffer_t pXformData) { PTRefNum_t refNum; SpStatus_t spStatus; KpUInt32_t PTDatasize; PTErr_t PTStat; KpUInt32_t MFType; KpInt32_t KcmDataType; spStatus = SpDTtoKcmDT (SpDataType, &KcmDataType); if (spStatus != SpStatSuccess) { return (spStatus); } /* Get the Color Processor PTRefNum of the SpXform */ spStatus = SpXformGetRefNum (spXform, &refNum); if (SpStatSuccess != spStatus) return spStatus; /* determine type of transform to get */ switch (LutType) { case SP_ICC_FUT: MFType = PTTYPE_FUTF; break; case SP_ICC_MFT1: MFType = PTTYPE_MFT1; break; case SP_ICC_MFT2: if (KcmDataType == KCM_ICC_TYPE_0) MFType = PTTYPE_MFT2_VER_0; else MFType = PTTYPE_MFT2; break; case SP_ICC_MAB1: MFType = PTTYPE_MAB1; break; case SP_ICC_MAB2: MFType = PTTYPE_MAB2; break; case SP_ICC_MBA1: MFType = PTTYPE_MBA1; break; case SP_ICC_MBA2: MFType = PTTYPE_MBA2; break; default: return SpStatOutOfRange; } /* ask color processor for the size of the Transform */ PTStat = PTGetSizeF (refNum, MFType, (KpInt32_t FAR *)&PTDatasize); if (KCP_SUCCESS != PTStat) return SpStatusFromPTErr(PTStat); if (PTDatasize > Datasize) return SpStatBufferTooSmall; #if defined KCP_DIAG_LOG {KpChar_t string[256]; sprintf (string, "\nSpXformToBufferDT\n spXform %x, PTRefNum %x", spXform, pXformData); kcpDiagLog (string); } #endif /* ask color processor for the Transform data */ PTStat = PTGetPTF(refNum, MFType, Datasize, (PTAddr_t) pXformData); return SpStatusFromPTErr(PTStat); }