📄 cmsio0.c
字号:
NewIcc ->IsWrite = FALSE; return NewIcc;}// Creates a profile from memory read placeholderLPLCMSICCPROFILE _cmsCreateProfileFromMemPlaceholder(LPVOID MemPtr, DWORD dwSize){ LPLCMSICCPROFILE NewIcc; LPVOID ICCfile = MemoryOpen((LPBYTE) MemPtr, (size_t) dwSize, 'r'); if (ICCfile == NULL) { cmsSignalError(LCMS_ERRC_ABORTED, "Couldn't allocate %ld bytes for profile", dwSize); return NULL; } NewIcc = (LPLCMSICCPROFILE) _cmsCreateProfilePlaceholder(); if (NewIcc == NULL) return NULL; NewIcc -> PhysicalFile[0] = 0; NewIcc ->stream = ICCfile; NewIcc ->Read = MemoryRead; NewIcc ->Seek = MemorySeek; NewIcc ->Tell = MemoryTell; NewIcc ->Close = MemoryClose; NewIcc ->Write = NULL; NewIcc ->IsWrite = FALSE; return NewIcc;}// Turn a placeholder into file writtervoid _cmsSetSaveToDisk(LPLCMSICCPROFILE Icc, const char* FileName){ if (FileName == NULL) { Icc ->stream = NULL; } else { Icc ->stream = fopen(FileName, "wb"); if (Icc ->stream == NULL) cmsSignalError(LCMS_ERRC_ABORTED, "Couldn't write to file '%s'", FileName); } Icc ->Write = FileWrite; // Save to disk Icc ->Close = FileClose;}// Turn a placeholder into memory writtervoid _cmsSetSaveToMemory(LPLCMSICCPROFILE Icc, LPVOID MemPtr, size_t dwSize){ if (MemPtr == NULL) { Icc ->stream = NULL; } else { Icc ->stream = (FILEMEM*) MemoryOpen((LPBYTE) MemPtr, dwSize, 'w'); if (Icc ->stream == NULL) cmsSignalError(LCMS_ERRC_ABORTED, "Couldn't write to memory"); } Icc ->Write = MemoryWrite; Icc ->Close = MemoryClose;}// ----------------------------------------------------------------------- Set/Get several struct membersBOOL LCMSEXPORT cmsTakeMediaWhitePoint(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; *Dest = Icc -> MediaWhitePoint; return TRUE;}BOOL LCMSEXPORT cmsTakeMediaBlackPoint(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; *Dest = Icc -> MediaBlackPoint; return TRUE;}BOOL LCMSEXPORT cmsTakeIluminant(LPcmsCIEXYZ Dest, cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; *Dest = Icc -> Illuminant; return TRUE;}int LCMSEXPORT cmsTakeRenderingIntent(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return (int) Icc -> RenderingIntent;}void LCMSEXPORT cmsSetRenderingIntent(cmsHPROFILE hProfile, int RenderingIntent){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> RenderingIntent = (icRenderingIntent) RenderingIntent;}DWORD LCMSEXPORT cmsTakeHeaderFlags(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return (DWORD) Icc -> flags;}void LCMSEXPORT cmsSetHeaderFlags(cmsHPROFILE hProfile, DWORD Flags){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> flags = (icUInt32Number) Flags;}DWORD LCMSEXPORT cmsTakeHeaderAttributes(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return (DWORD) Icc -> attributes;}void LCMSEXPORT cmsSetHeaderAttributes(cmsHPROFILE hProfile, DWORD Flags){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> attributes = (icUInt32Number) Flags;}const BYTE* LCMSEXPORT cmsTakeProfileID(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return Icc ->ProfileID;}void LCMSEXPORT cmsSetProfileID(cmsHPROFILE hProfile, LPBYTE ProfileID){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; CopyMemory(Icc -> ProfileID, ProfileID, 16);}BOOL LCMSEXPORT cmsTakeCreationDateTime(struct tm *Dest, cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; CopyMemory(Dest, &Icc ->Created, sizeof(struct tm)); return TRUE;}icColorSpaceSignature LCMSEXPORT cmsGetPCS(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return Icc -> PCS;}void LCMSEXPORT cmsSetPCS(cmsHPROFILE hProfile, icColorSpaceSignature pcs){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> PCS = pcs;}icColorSpaceSignature LCMSEXPORT cmsGetColorSpace(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return Icc -> ColorSpace;}void LCMSEXPORT cmsSetColorSpace(cmsHPROFILE hProfile, icColorSpaceSignature sig){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> ColorSpace = sig;}icProfileClassSignature LCMSEXPORT cmsGetDeviceClass(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return Icc -> DeviceClass;}DWORD LCMSEXPORT cmsGetProfileICCversion(cmsHPROFILE hProfile){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; return (DWORD) Icc -> Version;}void LCMSEXPORT cmsSetProfileICCversion(cmsHPROFILE hProfile, DWORD Version){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> Version = Version;}void LCMSEXPORT cmsSetDeviceClass(cmsHPROFILE hProfile, icProfileClassSignature sig){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) hProfile; Icc -> DeviceClass = sig;}// --------------------------------------------------------------------------------------------------------------staticint SizeOfGammaTab(LPGAMMATABLE In){ return sizeof(GAMMATABLE) + (In -> nEntries - 1)*sizeof(WORD);}// Creates a phantom tag holding a memory blockstaticLPVOID DupBlock(LPLCMSICCPROFILE Icc, LPVOID Block, size_t size){ if (Block != NULL && size > 0) return _cmsInitTag(Icc, (icTagSignature) 0, size, Block); else return NULL;}// This is tricky, since LUT structs does have pointersBOOL LCMSEXPORT _cmsAddLUTTag(cmsHPROFILE hProfile, icTagSignature sig, LPVOID lut){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; LPLUT Orig, Stored; unsigned int i; // The struct itself Orig = (LPLUT) lut; Stored = (LPLUT) _cmsInitTag(Icc, (icTagSignature) sig, sizeof(LUT), lut); // dup' the memory blocks for (i=0; i < Orig ->InputChan; i++) Stored -> L1[i] = (LPWORD) DupBlock(Icc, (LPWORD) Orig ->L1[i], sizeof(WORD) * Orig ->In16params.nSamples); for (i=0; i < Orig ->OutputChan; i++) Stored -> L2[i] = (LPWORD) DupBlock(Icc, (LPWORD) Orig ->L2[i], sizeof(WORD) * Orig ->Out16params.nSamples); Stored -> T = (LPWORD) DupBlock(Icc, (LPWORD) Orig ->T, Orig -> Tsize); // Zero any additional pointer Stored ->CLut16params.p8 = NULL; return TRUE;}BOOL LCMSEXPORT _cmsAddXYZTag(cmsHPROFILE hProfile, icTagSignature sig, const cmsCIEXYZ* XYZ){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, sizeof(cmsCIEXYZ), XYZ); return TRUE;}BOOL LCMSEXPORT _cmsAddTextTag(cmsHPROFILE hProfile, icTagSignature sig, const char* Text){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, strlen(Text)+1, (LPVOID) Text); return TRUE;}BOOL LCMSEXPORT _cmsAddGammaTag(cmsHPROFILE hProfile, icTagSignature sig, LPGAMMATABLE TransferFunction){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, SizeOfGammaTab(TransferFunction), TransferFunction); return TRUE;}BOOL LCMSEXPORT _cmsAddChromaticityTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsCIExyYTRIPLE Chrm){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, sizeof(cmsCIExyYTRIPLE), Chrm); return TRUE;}BOOL LCMSEXPORT _cmsAddSequenceDescriptionTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsSEQ pseq){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, sizeof(int) + pseq -> n * sizeof(cmsPSEQDESC), pseq); return TRUE;}BOOL LCMSEXPORT _cmsAddNamedColorTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsNAMEDCOLORLIST nc){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, sizeof(cmsNAMEDCOLORLIST) + (nc ->nColors - 1) * sizeof(cmsNAMEDCOLOR), nc); return FALSE;}BOOL LCMSEXPORT _cmsAddDateTimeTag(cmsHPROFILE hProfile, icTagSignature sig, struct tm *DateTime){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, sizeof(struct tm), DateTime); return FALSE;}BOOL LCMSEXPORT _cmsAddColorantTableTag(cmsHPROFILE hProfile, icTagSignature sig, LPcmsNAMEDCOLORLIST nc){ LPLCMSICCPROFILE Icc = (LPLCMSICCPROFILE) (LPSTR) hProfile; _cmsInitTag(Icc, sig, sizeof(cmsNAMEDCOLORLIST) + (nc ->nColors - 1) * sizeof(cmsNAMEDCOLOR), nc); return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -