/*-------------------------------------------------------------------- * DESCRIPTION (Public) * Load a profile from a file. * * AUTHOR * doro * * DATE CREATED * December 5, 1995 *------------------------------------------------------------------*/ SpStatus_t KSPAPI SpProfileLoadProfile ( SpCallerId_t CallerId, KpChar_t *FileName, SpFileProps_t *Props, SpProfile_t FAR *Profile) { KpMapFile_t MapFileCtl; KpFileProps_t props; SpStatus_t Status; char KPHUGE *Ptr; KpInt32_t ProfileSize; #if defined (KPMAC) /* Convert file information into useable form */ SpCvrtSpFileProps(Props, &props); #endif /* Map the file */ if (NULL == KpMapFileEx (FileName, &props, "r", &MapFileCtl)) return SpStatFileNotFound; Ptr = (char *)MapFileCtl.Ptr; ProfileSize = (KpInt32_t)SpGetUInt32 (&Ptr); if (ProfileSize > MapFileCtl.NumBytes) { KpUnMapFile (&MapFileCtl); return SpStatBadProfile; } /* Load the profile */ Status = SpProfileLoadFromBuffer (CallerId, MapFileCtl.Ptr, Profile); /* Unmap the file */ KpUnMapFile (&MapFileCtl); /* Remember the file name */ if (SpStatSuccess == Status) { Status = SpProfileSetName (*Profile, FileName, Props); if (SpStatSuccess != Status) SpProfileFree (Profile); } return Status; }
/* getPTFromFile * * This routine is used when the uvL/LAB conversion PTs are * read from a file versus being generated by sprofile * * Only PTs are supported by this routine. */ KpInt32_t getPTFromFile(SpDirection_t direction, KpInt32_t Render, PTRefNum_t *thePT) { KpMapFile_t mappedFile; KpFileProps_t props; KpChar_p file; if (direction == SpDir2LAB) file = uvl2labName; else { switch (Render) { case KCM_COLORIMETRIC: file = lab2uvlCName; break; case KCM_SATURATION_MATCH: file = lab2uvlSName; break; case KCM_PERCEPTUAL: default: file = lab2uvlPName; break; } } if( !KpMapFileEx(file,&props,"r",&mappedFile) ) return -1; if( PTCheckIn(thePT,mappedFile.Ptr) != KCP_SUCCESS ) { KpUnMapFile(&mappedFile); return -1; } if( PTActivate(*thePT,mappedFile.NumBytes,mappedFile.Ptr) != KCP_SUCCESS ) { KpUnMapFile(&mappedFile); PTCheckOut( *thePT ); return -1; } KpUnMapFile(&mappedFile); return 0; }