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