/* PTGetSize calculates the size of a PT in FuT format. */ PTErr_t PTGetSize ( PTRefNum_t PTRefNum, KpInt32_p mBlkSize) { PTErr_t errnum; errnum = PTGetSizeF (PTRefNum, PTTYPE_FUTF, mBlkSize); return (errnum); }
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); }
/* PTGetPTF writes a PT to external memory in a variety of formats. */ PTErr_t PTGetPTF ( PTRefNum_t PTRefNum, PTType_t format, KpInt32_t mBlkSize, PTAddr_t PTAddr) { PTErr_t errnum, PTstatus; KpHandle_t PTHdr, PTAttr, PTData; KpFd_t fd; KpInt32_t attrSize, resultSize, nBytes; PTRefNum_t resizePTRefNum = 0, thePTRefNum; KpChar_p memData; errnum = getPTStatus (PTRefNum); if ((errnum == KCP_PT_ACTIVE) || (errnum == KCP_PT_INACTIVE) || (errnum == KCP_SERIAL_PT)) { #if defined KCP_DIAG_LOG {KpChar_t string[256]; sprintf (string, "\nPTGetPTF\n PTRefNum %x, format %x, mBlkSize %d, PTAddr %x\n", PTRefNum, format, mBlkSize, PTAddr); kcpDiagLog (string);} #endif PTstatus = errnum; /* verify the dimensions of the grid table are valid for the specified format. */ errnum = gridDimValid (format, PTRefNum, &resizePTRefNum); if (errnum != KCP_SUCCESS) { goto ErrOut1; } if (resizePTRefNum != 0) { thePTRefNum = resizePTRefNum; /* resized PT made */ } else { thePTRefNum = PTRefNum; /* use original PT */ } /* determine the size the resized PT */ errnum = PTGetSizeF (thePTRefNum, format, &resultSize); if (errnum != KCP_SUCCESS) { goto ErrOut1; } if (resultSize > mBlkSize) { /* PT may not be larger than the buffer size */ errnum = KCP_PT_BLOCK_TOO_SMALL; goto ErrOut1; } PTAttr = getPTAttr (thePTRefNum); PTHdr = getPTHdr (thePTRefNum); PTData = getPTData (thePTRefNum); /* initialize memory file manager to write the PT */ if (KpOpen (NULL, "m", &fd, NULL, (KpGenericPtr_t)PTAddr, mBlkSize) != KCMS_IO_SUCCESS) { errnum = KCP_SYSERR_1; goto ErrOut1; } attrSize = getAttrSize (PTAttr); /* get size of attributes */ errnum = TpWriteHdr (&fd, format, PTHdr, attrSize); /* write the header info */ if (errnum != KCP_SUCCESS) { Kp_close (&fd); goto ErrOut1; } #if !defined KCP_ICC_ONLY switch (format) { case PTTYPE_FUTF: errnum = writeAttributes (&fd, PTAttr); /* write the attributes */ if (errnum != KCP_SUCCESS) { break; } default: break; } #endif /* if PT active, write data to external format */ if (((PTstatus == KCP_PT_ACTIVE) || (PTstatus == KCP_SERIAL_PT)) && (errnum == KCP_SUCCESS)) { errnum = TpWriteData (&fd, format, PTHdr, PTData); } (void) Kp_close (&fd); /* if the result PT size is smaller than the memory block size fill the end of the memory block with zeros */ nBytes = mBlkSize - resultSize; if (nBytes > 0) { memData = (KpChar_p)PTAddr + resultSize; while (nBytes--) { *memData++ = 0; } } } ErrOut1: if (resizePTRefNum != 0) { PTCheckOut (resizePTRefNum); } return (errnum); }