| 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 "../../../include/fxcodec/fx_codec.h" | 7 #include "../../../include/fxcodec/fx_codec.h" |
| 8 #include "codec_int.h" | 8 #include "codec_int.h" |
| 9 #include "../lcms2/include/fx_lcms2.h" | 9 #include "../lcms2/include/fx_lcms2.h" |
| 10 const FX_DWORD N_COMPONENT_LAB = 3; | 10 const FX_DWORD N_COMPONENT_LAB = 3; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return cs; | 278 return cs; |
| 279 } | 279 } |
| 280 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) | 280 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) |
| 281 { | 281 { |
| 282 if (pFile == NULL) { | 282 if (pFile == NULL) { |
| 283 return IccCS_Unknown; | 283 return IccCS_Unknown; |
| 284 } | 284 } |
| 285 ICodec_IccModule::IccCS cs; | 285 ICodec_IccModule::IccCS cs; |
| 286 FX_DWORD dwSize = (FX_DWORD)pFile->GetSize(); | 286 FX_DWORD dwSize = (FX_DWORD)pFile->GetSize(); |
| 287 FX_LPBYTE pBuf = FX_Alloc(FX_BYTE, dwSize); | 287 FX_LPBYTE pBuf = FX_Alloc(FX_BYTE, dwSize); |
| 288 if (pBuf == NULL) { | |
| 289 return IccCS_Unknown; | |
| 290 } | |
| 291 pFile->ReadBlock(pBuf, 0, dwSize); | 288 pFile->ReadBlock(pBuf, 0, dwSize); |
| 292 cs = GetProfileCS(pBuf, dwSize); | 289 cs = GetProfileCS(pBuf, dwSize); |
| 293 FX_Free(pBuf); | 290 FX_Free(pBuf); |
| 294 return cs; | 291 return cs; |
| 295 } | 292 } |
| 296 FX_DWORD TransferProfileType(FX_LPVOID pProfile, FX_DWORD dwFormat) | 293 FX_DWORD TransferProfileType(FX_LPVOID pProfile, FX_DWORD dwFormat) |
| 297 { | 294 { |
| 298 cmsColorSpaceSignature cs = cmsGetColorSpace(pProfile); | 295 cmsColorSpaceSignature cs = cmsGetColorSpace(pProfile); |
| 299 switch (cs) { | 296 switch (cs) { |
| 300 case cmsSigXYZData: | 297 case cmsSigXYZData: |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } | 481 } |
| 485 FX_LPVOID pProofProfile = NULL; | 482 FX_LPVOID pProofProfile = NULL; |
| 486 if (pProofParam) { | 483 if (pProofParam) { |
| 487 pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key); | 484 pProofProfile = CreateProfile(pProofParam, Icc_CLASS_PROOF, &key); |
| 488 } | 485 } |
| 489 key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag << (p
ProofProfile != NULL) << dwPrfIntent << dwPrfFlag; | 486 key << dwInputProfileType << dwOutputProfileType << dwIntent << dwFlag << (p
ProofProfile != NULL) << dwPrfIntent << dwPrfFlag; |
| 490 CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); | 487 CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); |
| 491 CFX_IccTransformCache* pTransformCache; | 488 CFX_IccTransformCache* pTransformCache; |
| 492 if (!m_MapTranform.Lookup(TransformKey, (FX_LPVOID&)pTransformCache)) { | 489 if (!m_MapTranform.Lookup(TransformKey, (FX_LPVOID&)pTransformCache)) { |
| 493 pCmm = FX_Alloc(CLcmsCmm, 1); | 490 pCmm = FX_Alloc(CLcmsCmm, 1); |
| 494 if (pCmm == NULL) { | |
| 495 return NULL; | |
| 496 } | |
| 497 pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType); | 491 pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType); |
| 498 pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType); | 492 pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType); |
| 499 pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab; | 493 pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab; |
| 500 pTransformCache = new CFX_IccTransformCache(pCmm); | 494 pTransformCache = new CFX_IccTransformCache(pCmm); |
| 501 if (pProofProfile) { | 495 if (pProofProfile) { |
| 502 pTransformCache->m_pIccTransform = cmsCreateProofingTransform(pInput
Profile, dwInputProfileType, pOutputProfile, dwOutputProfileType, | 496 pTransformCache->m_pIccTransform = cmsCreateProofingTransform(pInput
Profile, dwInputProfileType, pOutputProfile, dwOutputProfileType, |
| 503 pProofProfile, dwIntent, dwPrfInt
ent, dwPrfFlag); | 497 pProofProfile, dwIntent, dwPrfInt
ent, dwPrfFlag); |
| 504 } else { | 498 } else { |
| 505 pTransformCache->m_pIccTransform = cmsCreateTransform(pInputProfile,
dwInputProfileType, pOutputProfile, dwOutputProfileType, | 499 pTransformCache->m_pIccTransform = cmsCreateTransform(pInputProfile,
dwInputProfileType, pOutputProfile, dwOutputProfileType, |
| 506 dwIntent, dwFlag); | 500 dwIntent, dwFlag); |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 FX_BYTE c1 = FXSYS_round(c * 255); | 1360 FX_BYTE c1 = FXSYS_round(c * 255); |
| 1367 FX_BYTE m1 = FXSYS_round(m * 255); | 1361 FX_BYTE m1 = FXSYS_round(m * 255); |
| 1368 FX_BYTE y1 = FXSYS_round(y * 255); | 1362 FX_BYTE y1 = FXSYS_round(y * 255); |
| 1369 FX_BYTE k1 = FXSYS_round(k * 255); | 1363 FX_BYTE k1 = FXSYS_round(k * 255); |
| 1370 FX_BYTE r, g, b; | 1364 FX_BYTE r, g, b; |
| 1371 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); | 1365 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); |
| 1372 R = 1.0f * r / 255; | 1366 R = 1.0f * r / 255; |
| 1373 G = 1.0f * g / 255; | 1367 G = 1.0f * g / 255; |
| 1374 B = 1.0f * b / 255; | 1368 B = 1.0f * b / 255; |
| 1375 } | 1369 } |
| OLD | NEW |