| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fxcodec/codec/codec_int.h" | 7 #include "core/fxcodec/codec/codec_int.h" |
| 8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
| 9 #include "third_party/lcms2-2.6/include/lcms2.h" | 9 #include "third_party/lcms2-2.6/include/lcms2.h" |
| 10 | 10 |
| 11 const FX_DWORD N_COMPONENT_LAB = 3; | 11 const uint32_t N_COMPONENT_LAB = 3; |
| 12 const FX_DWORD N_COMPONENT_GRAY = 1; | 12 const uint32_t N_COMPONENT_GRAY = 1; |
| 13 const FX_DWORD N_COMPONENT_RGB = 3; | 13 const uint32_t N_COMPONENT_RGB = 3; |
| 14 const FX_DWORD N_COMPONENT_CMYK = 4; | 14 const uint32_t N_COMPONENT_CMYK = 4; |
| 15 const FX_DWORD N_COMPONENT_DEFAULT = 3; | 15 const uint32_t N_COMPONENT_DEFAULT = 3; |
| 16 | 16 |
| 17 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]) { | 17 FX_BOOL MD5ComputeID(const void* buf, uint32_t dwSize, uint8_t ID[16]) { |
| 18 return cmsMD5computeIDExt(buf, dwSize, ID); | 18 return cmsMD5computeIDExt(buf, dwSize, ID); |
| 19 } | 19 } |
| 20 struct CLcmsCmm { | 20 struct CLcmsCmm { |
| 21 cmsHTRANSFORM m_hTransform; | 21 cmsHTRANSFORM m_hTransform; |
| 22 int m_nSrcComponents; | 22 int m_nSrcComponents; |
| 23 int m_nDstComponents; | 23 int m_nDstComponents; |
| 24 FX_BOOL m_bLab; | 24 FX_BOOL m_bLab; |
| 25 }; | 25 }; |
| 26 extern "C" { | 26 extern "C" { |
| 27 int ourHandler(int ErrorCode, const char* ErrorText) { | 27 int ourHandler(int ErrorCode, const char* ErrorText) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 break; | 60 break; |
| 61 default: | 61 default: |
| 62 if (nComponents != 3) { | 62 if (nComponents != 3) { |
| 63 return FALSE; | 63 return FALSE; |
| 64 } | 64 } |
| 65 break; | 65 break; |
| 66 } | 66 } |
| 67 return TRUE; | 67 return TRUE; |
| 68 } | 68 } |
| 69 | 69 |
| 70 FX_DWORD GetCSComponents(cmsColorSpaceSignature cs) { | 70 uint32_t GetCSComponents(cmsColorSpaceSignature cs) { |
| 71 FX_DWORD components; | 71 uint32_t components; |
| 72 switch (cs) { | 72 switch (cs) { |
| 73 case cmsSigLabData: | 73 case cmsSigLabData: |
| 74 components = N_COMPONENT_LAB; | 74 components = N_COMPONENT_LAB; |
| 75 break; | 75 break; |
| 76 case cmsSigGrayData: | 76 case cmsSigGrayData: |
| 77 components = N_COMPONENT_GRAY; | 77 components = N_COMPONENT_GRAY; |
| 78 break; | 78 break; |
| 79 case cmsSigRgbData: | 79 case cmsSigRgbData: |
| 80 components = N_COMPONENT_RGB; | 80 components = N_COMPONENT_RGB; |
| 81 break; | 81 break; |
| 82 case cmsSigCmykData: | 82 case cmsSigCmykData: |
| 83 components = N_COMPONENT_CMYK; | 83 components = N_COMPONENT_CMYK; |
| 84 break; | 84 break; |
| 85 default: | 85 default: |
| 86 components = N_COMPONENT_DEFAULT; | 86 components = N_COMPONENT_DEFAULT; |
| 87 break; | 87 break; |
| 88 } | 88 } |
| 89 return components; | 89 return components; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, | 92 void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, |
| 93 FX_DWORD dwSrcProfileSize, | 93 uint32_t dwSrcProfileSize, |
| 94 FX_DWORD& nSrcComponents, | 94 uint32_t& nSrcComponents, |
| 95 const unsigned char* pDstProfileData, | 95 const unsigned char* pDstProfileData, |
| 96 FX_DWORD dwDstProfileSize, | 96 uint32_t dwDstProfileSize, |
| 97 int32_t nDstComponents, | 97 int32_t nDstComponents, |
| 98 int intent, | 98 int intent, |
| 99 FX_DWORD dwSrcFormat = Icc_FORMAT_DEFAULT, | 99 uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT, |
| 100 FX_DWORD dwDstFormat = Icc_FORMAT_DEFAULT) { | 100 uint32_t dwDstFormat = Icc_FORMAT_DEFAULT) { |
| 101 cmsHPROFILE srcProfile = NULL; | 101 cmsHPROFILE srcProfile = NULL; |
| 102 cmsHPROFILE dstProfile = NULL; | 102 cmsHPROFILE dstProfile = NULL; |
| 103 cmsHTRANSFORM hTransform = NULL; | 103 cmsHTRANSFORM hTransform = NULL; |
| 104 CLcmsCmm* pCmm = NULL; | 104 CLcmsCmm* pCmm = NULL; |
| 105 nSrcComponents = 0; | 105 nSrcComponents = 0; |
| 106 srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize); | 106 srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize); |
| 107 if (!srcProfile) { | 107 if (!srcProfile) { |
| 108 return NULL; | 108 return NULL; |
| 109 } | 109 } |
| 110 if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) { | 110 if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 pCmm = new CLcmsCmm; | 163 pCmm = new CLcmsCmm; |
| 164 pCmm->m_nSrcComponents = nSrcComponents; | 164 pCmm->m_nSrcComponents = nSrcComponents; |
| 165 pCmm->m_nDstComponents = nDstComponents; | 165 pCmm->m_nDstComponents = nDstComponents; |
| 166 pCmm->m_hTransform = hTransform; | 166 pCmm->m_hTransform = hTransform; |
| 167 pCmm->m_bLab = bLab; | 167 pCmm->m_bLab = bLab; |
| 168 cmsCloseProfile(srcProfile); | 168 cmsCloseProfile(srcProfile); |
| 169 cmsCloseProfile(dstProfile); | 169 cmsCloseProfile(dstProfile); |
| 170 return pCmm; | 170 return pCmm; |
| 171 } | 171 } |
| 172 void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, | 172 void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, |
| 173 FX_DWORD dwProfileSize, | 173 uint32_t dwProfileSize, |
| 174 FX_DWORD& nComponents, | 174 uint32_t& nComponents, |
| 175 int32_t intent, | 175 int32_t intent, |
| 176 FX_DWORD dwSrcFormat) { | 176 uint32_t dwSrcFormat) { |
| 177 return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, | 177 return IccLib_CreateTransform(pProfileData, dwProfileSize, nComponents, NULL, |
| 178 0, 3, intent, dwSrcFormat); | 178 0, 3, intent, dwSrcFormat); |
| 179 } | 179 } |
| 180 void IccLib_DestroyTransform(void* pTransform) { | 180 void IccLib_DestroyTransform(void* pTransform) { |
| 181 if (!pTransform) { | 181 if (!pTransform) { |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform); | 184 cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform); |
| 185 delete (CLcmsCmm*)pTransform; | 185 delete (CLcmsCmm*)pTransform; |
| 186 } | 186 } |
| 187 void IccLib_Translate(void* pTransform, | 187 void IccLib_Translate(void* pTransform, |
| 188 FX_DWORD nSrcComponents, | 188 uint32_t nSrcComponents, |
| 189 FX_FLOAT* pSrcValues, | 189 FX_FLOAT* pSrcValues, |
| 190 FX_FLOAT* pDestValues) { | 190 FX_FLOAT* pDestValues) { |
| 191 if (!pTransform) { | 191 if (!pTransform) { |
| 192 return; | 192 return; |
| 193 } | 193 } |
| 194 CLcmsCmm* p = (CLcmsCmm*)pTransform; | 194 CLcmsCmm* p = (CLcmsCmm*)pTransform; |
| 195 uint8_t output[4]; | 195 uint8_t output[4]; |
| 196 if (p->m_bLab) { | 196 if (p->m_bLab) { |
| 197 CFX_FixedBufGrow<double, 16> inputs(nSrcComponents); | 197 CFX_FixedBufGrow<double, 16> inputs(nSrcComponents); |
| 198 double* input = inputs; | 198 double* input = inputs; |
| 199 for (FX_DWORD i = 0; i < nSrcComponents; i++) { | 199 for (uint32_t i = 0; i < nSrcComponents; i++) { |
| 200 input[i] = pSrcValues[i]; | 200 input[i] = pSrcValues[i]; |
| 201 } | 201 } |
| 202 cmsDoTransform(p->m_hTransform, input, output, 1); | 202 cmsDoTransform(p->m_hTransform, input, output, 1); |
| 203 } else { | 203 } else { |
| 204 CFX_FixedBufGrow<uint8_t, 16> inputs(nSrcComponents); | 204 CFX_FixedBufGrow<uint8_t, 16> inputs(nSrcComponents); |
| 205 uint8_t* input = inputs; | 205 uint8_t* input = inputs; |
| 206 for (FX_DWORD i = 0; i < nSrcComponents; i++) { | 206 for (uint32_t i = 0; i < nSrcComponents; i++) { |
| 207 if (pSrcValues[i] > 1.0f) { | 207 if (pSrcValues[i] > 1.0f) { |
| 208 input[i] = 255; | 208 input[i] = 255; |
| 209 } else if (pSrcValues[i] < 0) { | 209 } else if (pSrcValues[i] < 0) { |
| 210 input[i] = 0; | 210 input[i] = 0; |
| 211 } else { | 211 } else { |
| 212 input[i] = (int)(pSrcValues[i] * 255.0f); | 212 input[i] = (int)(pSrcValues[i] * 255.0f); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 cmsDoTransform(p->m_hTransform, input, output, 1); | 215 cmsDoTransform(p->m_hTransform, input, output, 1); |
| 216 } | 216 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 case cmsSigCmykData: | 277 case cmsSigCmykData: |
| 278 return ICodec_IccModule::IccCS_Cmyk; | 278 return ICodec_IccModule::IccCS_Cmyk; |
| 279 case cmsSigCmyData: | 279 case cmsSigCmyData: |
| 280 return ICodec_IccModule::IccCS_Cmy; | 280 return ICodec_IccModule::IccCS_Cmy; |
| 281 default: | 281 default: |
| 282 return ICodec_IccModule::IccCS_Unknown; | 282 return ICodec_IccModule::IccCS_Unknown; |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( | 285 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( |
| 286 const uint8_t* pProfileData, | 286 const uint8_t* pProfileData, |
| 287 FX_DWORD dwProfileSize) { | 287 uint32_t dwProfileSize) { |
| 288 ICodec_IccModule::IccCS cs; | 288 ICodec_IccModule::IccCS cs; |
| 289 cmsHPROFILE hProfile = | 289 cmsHPROFILE hProfile = |
| 290 cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize); | 290 cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize); |
| 291 if (!hProfile) { | 291 if (!hProfile) { |
| 292 return IccCS_Unknown; | 292 return IccCS_Unknown; |
| 293 } | 293 } |
| 294 cs = GetProfileCSFromHandle(hProfile); | 294 cs = GetProfileCSFromHandle(hProfile); |
| 295 if (hProfile) { | 295 if (hProfile) { |
| 296 cmsCloseProfile(hProfile); | 296 cmsCloseProfile(hProfile); |
| 297 } | 297 } |
| 298 return cs; | 298 return cs; |
| 299 } | 299 } |
| 300 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) { | 300 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) { |
| 301 if (!pFile) { | 301 if (!pFile) { |
| 302 return IccCS_Unknown; | 302 return IccCS_Unknown; |
| 303 } | 303 } |
| 304 ICodec_IccModule::IccCS cs; | 304 ICodec_IccModule::IccCS cs; |
| 305 FX_DWORD dwSize = (FX_DWORD)pFile->GetSize(); | 305 uint32_t dwSize = (uint32_t)pFile->GetSize(); |
| 306 uint8_t* pBuf = FX_Alloc(uint8_t, dwSize); | 306 uint8_t* pBuf = FX_Alloc(uint8_t, dwSize); |
| 307 pFile->ReadBlock(pBuf, 0, dwSize); | 307 pFile->ReadBlock(pBuf, 0, dwSize); |
| 308 cs = GetProfileCS(pBuf, dwSize); | 308 cs = GetProfileCS(pBuf, dwSize); |
| 309 FX_Free(pBuf); | 309 FX_Free(pBuf); |
| 310 return cs; | 310 return cs; |
| 311 } | 311 } |
| 312 FX_DWORD TransferProfileType(void* pProfile, FX_DWORD dwFormat) { | 312 uint32_t TransferProfileType(void* pProfile, uint32_t dwFormat) { |
| 313 cmsColorSpaceSignature cs = cmsGetColorSpace(pProfile); | 313 cmsColorSpaceSignature cs = cmsGetColorSpace(pProfile); |
| 314 switch (cs) { | 314 switch (cs) { |
| 315 case cmsSigXYZData: | 315 case cmsSigXYZData: |
| 316 return TYPE_XYZ_16; | 316 return TYPE_XYZ_16; |
| 317 case cmsSigLabData: | 317 case cmsSigLabData: |
| 318 return TYPE_Lab_DBL; | 318 return TYPE_Lab_DBL; |
| 319 case cmsSigLuvData: | 319 case cmsSigLuvData: |
| 320 return TYPE_YUV_8; | 320 return TYPE_YUV_8; |
| 321 case cmsSigYCbCrData: | 321 case cmsSigYCbCrData: |
| 322 return TYPE_YCbCr_8; | 322 return TYPE_YCbCr_8; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 352 return T_DOSWAP(dwFormat) ? TYPE_KYMC12_8 : TYPE_CMYK12_8; | 352 return T_DOSWAP(dwFormat) ? TYPE_KYMC12_8 : TYPE_CMYK12_8; |
| 353 default: | 353 default: |
| 354 return 0; | 354 return 0; |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 class CFX_IccProfileCache { | 357 class CFX_IccProfileCache { |
| 358 public: | 358 public: |
| 359 CFX_IccProfileCache(); | 359 CFX_IccProfileCache(); |
| 360 ~CFX_IccProfileCache(); | 360 ~CFX_IccProfileCache(); |
| 361 void* m_pProfile; | 361 void* m_pProfile; |
| 362 FX_DWORD m_dwRate; | 362 uint32_t m_dwRate; |
| 363 | 363 |
| 364 protected: | 364 protected: |
| 365 void Purge(); | 365 void Purge(); |
| 366 }; | 366 }; |
| 367 CFX_IccProfileCache::CFX_IccProfileCache() { | 367 CFX_IccProfileCache::CFX_IccProfileCache() { |
| 368 m_pProfile = NULL; | 368 m_pProfile = NULL; |
| 369 m_dwRate = 1; | 369 m_dwRate = 1; |
| 370 } | 370 } |
| 371 CFX_IccProfileCache::~CFX_IccProfileCache() { | 371 CFX_IccProfileCache::~CFX_IccProfileCache() { |
| 372 if (m_pProfile) { | 372 if (m_pProfile) { |
| 373 cmsCloseProfile(m_pProfile); | 373 cmsCloseProfile(m_pProfile); |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 void CFX_IccProfileCache::Purge() {} | 376 void CFX_IccProfileCache::Purge() {} |
| 377 class CFX_IccTransformCache { | 377 class CFX_IccTransformCache { |
| 378 public: | 378 public: |
| 379 CFX_IccTransformCache(CLcmsCmm* pCmm = NULL); | 379 CFX_IccTransformCache(CLcmsCmm* pCmm = NULL); |
| 380 ~CFX_IccTransformCache(); | 380 ~CFX_IccTransformCache(); |
| 381 void* m_pIccTransform; | 381 void* m_pIccTransform; |
| 382 FX_DWORD m_dwRate; | 382 uint32_t m_dwRate; |
| 383 CLcmsCmm* m_pCmm; | 383 CLcmsCmm* m_pCmm; |
| 384 | 384 |
| 385 protected: | 385 protected: |
| 386 void Purge(); | 386 void Purge(); |
| 387 }; | 387 }; |
| 388 CFX_IccTransformCache::CFX_IccTransformCache(CLcmsCmm* pCmm) { | 388 CFX_IccTransformCache::CFX_IccTransformCache(CLcmsCmm* pCmm) { |
| 389 m_pIccTransform = NULL; | 389 m_pIccTransform = NULL; |
| 390 m_dwRate = 1; | 390 m_dwRate = 1; |
| 391 m_pCmm = pCmm; | 391 m_pCmm = pCmm; |
| 392 } | 392 } |
| 393 CFX_IccTransformCache::~CFX_IccTransformCache() { | 393 CFX_IccTransformCache::~CFX_IccTransformCache() { |
| 394 if (m_pIccTransform) { | 394 if (m_pIccTransform) { |
| 395 cmsDeleteTransform(m_pIccTransform); | 395 cmsDeleteTransform(m_pIccTransform); |
| 396 } | 396 } |
| 397 FX_Free(m_pCmm); | 397 FX_Free(m_pCmm); |
| 398 } | 398 } |
| 399 void CFX_IccTransformCache::Purge() {} | 399 void CFX_IccTransformCache::Purge() {} |
| 400 class CFX_ByteStringKey : public CFX_BinaryBuf { | 400 class CFX_ByteStringKey : public CFX_BinaryBuf { |
| 401 public: | 401 public: |
| 402 CFX_ByteStringKey() : CFX_BinaryBuf() {} | 402 CFX_ByteStringKey() : CFX_BinaryBuf() {} |
| 403 CFX_ByteStringKey& operator<<(FX_DWORD i); | 403 CFX_ByteStringKey& operator<<(uint32_t i); |
| 404 }; | 404 }; |
| 405 CFX_ByteStringKey& CFX_ByteStringKey::operator<<(FX_DWORD i) { | 405 CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) { |
| 406 AppendBlock(&i, sizeof(FX_DWORD)); | 406 AppendBlock(&i, sizeof(uint32_t)); |
| 407 return *this; | 407 return *this; |
| 408 } | 408 } |
| 409 void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, | 409 void* CCodec_IccModule::CreateProfile(ICodec_IccModule::IccParam* pIccParam, |
| 410 Icc_CLASS ic, | 410 Icc_CLASS ic, |
| 411 CFX_BinaryBuf* pTransformKey) { | 411 CFX_BinaryBuf* pTransformKey) { |
| 412 CFX_IccProfileCache* pCache = NULL; | 412 CFX_IccProfileCache* pCache = NULL; |
| 413 CFX_ByteStringKey key; | 413 CFX_ByteStringKey key; |
| 414 CFX_ByteString text; | 414 CFX_ByteString text; |
| 415 key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8); | 415 key << pIccParam->ColorSpace << (pIccParam->dwProfileType | ic << 8); |
| 416 uint8_t ID[16]; | 416 uint8_t ID[16]; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 } else { | 465 } else { |
| 466 pCache = it->second; | 466 pCache = it->second; |
| 467 pCache->m_dwRate++; | 467 pCache->m_dwRate++; |
| 468 } | 468 } |
| 469 return pCache->m_pProfile; | 469 return pCache->m_pProfile; |
| 470 } | 470 } |
| 471 void* CCodec_IccModule::CreateTransform( | 471 void* CCodec_IccModule::CreateTransform( |
| 472 ICodec_IccModule::IccParam* pInputParam, | 472 ICodec_IccModule::IccParam* pInputParam, |
| 473 ICodec_IccModule::IccParam* pOutputParam, | 473 ICodec_IccModule::IccParam* pOutputParam, |
| 474 ICodec_IccModule::IccParam* pProofParam, | 474 ICodec_IccModule::IccParam* pProofParam, |
| 475 FX_DWORD dwIntent, | 475 uint32_t dwIntent, |
| 476 FX_DWORD dwFlag, | 476 uint32_t dwFlag, |
| 477 FX_DWORD dwPrfIntent, | 477 uint32_t dwPrfIntent, |
| 478 FX_DWORD dwPrfFlag) { | 478 uint32_t dwPrfFlag) { |
| 479 CLcmsCmm* pCmm = NULL; | 479 CLcmsCmm* pCmm = NULL; |
| 480 ASSERT(pInputParam && pOutputParam); | 480 ASSERT(pInputParam && pOutputParam); |
| 481 CFX_ByteStringKey key; | 481 CFX_ByteStringKey key; |
| 482 void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key); | 482 void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key); |
| 483 if (!pInputProfile) { | 483 if (!pInputProfile) { |
| 484 return NULL; | 484 return NULL; |
| 485 } | 485 } |
| 486 void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key); | 486 void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key); |
| 487 if (!pOutputProfile) { | 487 if (!pOutputProfile) { |
| 488 return NULL; | 488 return NULL; |
| 489 } | 489 } |
| 490 FX_DWORD dwInputProfileType = | 490 uint32_t dwInputProfileType = |
| 491 TransferProfileType(pInputProfile, pInputParam->dwFormat); | 491 TransferProfileType(pInputProfile, pInputParam->dwFormat); |
| 492 FX_DWORD dwOutputProfileType = | 492 uint32_t dwOutputProfileType = |
| 493 TransferProfileType(pOutputProfile, pOutputParam->dwFormat); | 493 TransferProfileType(pOutputProfile, pOutputParam->dwFormat); |
| 494 if (dwInputProfileType == 0 || dwOutputProfileType == 0) { | 494 if (dwInputProfileType == 0 || dwOutputProfileType == 0) { |
| 495 return NULL; | 495 return NULL; |
| 496 } | 496 } |
| 497 void* pProofProfile = NULL; | 497 void* pProofProfile = NULL; |
| 498 if (pProofParam) { | 498 if (pProofParam) { |
| 499 pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key); | 499 pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key); |
| 500 } | 500 } |
| 501 key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag | 501 key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag |
| 502 << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; | 502 << (pProofProfile != NULL) << dwPrfIntent << dwPrfFlag; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 530 for (const auto& pair : m_MapProfile) { | 530 for (const auto& pair : m_MapProfile) { |
| 531 delete pair.second; | 531 delete pair.second; |
| 532 } | 532 } |
| 533 m_MapProfile.clear(); | 533 m_MapProfile.clear(); |
| 534 for (const auto& pair : m_MapTranform) { | 534 for (const auto& pair : m_MapTranform) { |
| 535 delete pair.second; | 535 delete pair.second; |
| 536 } | 536 } |
| 537 m_MapTranform.clear(); | 537 m_MapTranform.clear(); |
| 538 } | 538 } |
| 539 void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData, | 539 void* CCodec_IccModule::CreateTransform_sRGB(const uint8_t* pProfileData, |
| 540 FX_DWORD dwProfileSize, | 540 uint32_t dwProfileSize, |
| 541 FX_DWORD& nComponents, | 541 uint32_t& nComponents, |
| 542 int32_t intent, | 542 int32_t intent, |
| 543 FX_DWORD dwSrcFormat) { | 543 uint32_t dwSrcFormat) { |
| 544 return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents, | 544 return IccLib_CreateTransform_sRGB(pProfileData, dwProfileSize, nComponents, |
| 545 intent, dwSrcFormat); | 545 intent, dwSrcFormat); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void* CCodec_IccModule::CreateTransform_CMYK(const uint8_t* pSrcProfileData, | 548 void* CCodec_IccModule::CreateTransform_CMYK(const uint8_t* pSrcProfileData, |
| 549 FX_DWORD dwSrcProfileSize, | 549 uint32_t dwSrcProfileSize, |
| 550 FX_DWORD& nSrcComponents, | 550 uint32_t& nSrcComponents, |
| 551 const uint8_t* pDstProfileData, | 551 const uint8_t* pDstProfileData, |
| 552 FX_DWORD dwDstProfileSize, | 552 uint32_t dwDstProfileSize, |
| 553 int32_t intent, | 553 int32_t intent, |
| 554 FX_DWORD dwSrcFormat, | 554 uint32_t dwSrcFormat, |
| 555 FX_DWORD dwDstFormat) { | 555 uint32_t dwDstFormat) { |
| 556 return IccLib_CreateTransform( | 556 return IccLib_CreateTransform( |
| 557 pSrcProfileData, dwSrcProfileSize, nSrcComponents, pDstProfileData, | 557 pSrcProfileData, dwSrcProfileSize, nSrcComponents, pDstProfileData, |
| 558 dwDstProfileSize, 4, intent, dwSrcFormat, dwDstFormat); | 558 dwDstProfileSize, 4, intent, dwSrcFormat, dwDstFormat); |
| 559 } | 559 } |
| 560 | 560 |
| 561 void CCodec_IccModule::DestroyTransform(void* pTransform) { | 561 void CCodec_IccModule::DestroyTransform(void* pTransform) { |
| 562 IccLib_DestroyTransform(pTransform); | 562 IccLib_DestroyTransform(pTransform); |
| 563 } | 563 } |
| 564 void CCodec_IccModule::Translate(void* pTransform, | 564 void CCodec_IccModule::Translate(void* pTransform, |
| 565 FX_FLOAT* pSrcValues, | 565 FX_FLOAT* pSrcValues, |
| (...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 uint8_t c1 = FXSYS_round(c * 255); | 1977 uint8_t c1 = FXSYS_round(c * 255); |
| 1978 uint8_t m1 = FXSYS_round(m * 255); | 1978 uint8_t m1 = FXSYS_round(m * 255); |
| 1979 uint8_t y1 = FXSYS_round(y * 255); | 1979 uint8_t y1 = FXSYS_round(y * 255); |
| 1980 uint8_t k1 = FXSYS_round(k * 255); | 1980 uint8_t k1 = FXSYS_round(k * 255); |
| 1981 uint8_t r, g, b; | 1981 uint8_t r, g, b; |
| 1982 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); | 1982 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); |
| 1983 R = 1.0f * r / 255; | 1983 R = 1.0f * r / 255; |
| 1984 G = 1.0f * g / 255; | 1984 G = 1.0f * g / 255; |
| 1985 B = 1.0f * b / 255; | 1985 B = 1.0f * b / 255; |
| 1986 } | 1986 } |
| OLD | NEW |