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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 intent, 0); | 141 intent, 0); |
142 break; | 142 break; |
143 default: | 143 default: |
144 break; | 144 break; |
145 } | 145 } |
146 if (hTransform == NULL) { | 146 if (hTransform == NULL) { |
147 cmsCloseProfile(srcProfile); | 147 cmsCloseProfile(srcProfile); |
148 cmsCloseProfile(dstProfile); | 148 cmsCloseProfile(dstProfile); |
149 return NULL; | 149 return NULL; |
150 } | 150 } |
151 pCmm = FX_NEW CLcmsCmm; | 151 pCmm = new CLcmsCmm; |
152 if (pCmm == NULL) { | |
153 return NULL; | |
154 } | |
155 pCmm->m_nSrcComponents = nSrcComponents; | 152 pCmm->m_nSrcComponents = nSrcComponents; |
156 pCmm->m_nDstComponents = nDstComponents; | 153 pCmm->m_nDstComponents = nDstComponents; |
157 pCmm->m_hTransform = hTransform; | 154 pCmm->m_hTransform = hTransform; |
158 pCmm->m_bLab = bLab; | 155 pCmm->m_bLab = bLab; |
159 cmsCloseProfile(srcProfile); | 156 cmsCloseProfile(srcProfile); |
160 cmsCloseProfile(dstProfile); | 157 cmsCloseProfile(dstProfile); |
161 return pCmm; | 158 return pCmm; |
162 } | 159 } |
163 void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, FX_DWORD dw
ProfileSize, FX_INT32& nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat) | 160 void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData, FX_DWORD dw
ProfileSize, FX_INT32& nComponents, FX_INT32 intent, FX_DWORD dwSrcFormat) |
164 { | 161 { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 MD5ComputeID(text.GetBuffer(0), text.GetLength(), ID); | 428 MD5ComputeID(text.GetBuffer(0), text.GetLength(), ID); |
432 break; | 429 break; |
433 default: | 430 default: |
434 ; | 431 ; |
435 } | 432 } |
436 key.AppendBlock(ID, 16); | 433 key.AppendBlock(ID, 16); |
437 CFX_ByteString ProfileKey(key.GetBuffer(), key.GetSize()); | 434 CFX_ByteString ProfileKey(key.GetBuffer(), key.GetSize()); |
438 ASSERT(pTransformKey); | 435 ASSERT(pTransformKey); |
439 pTransformKey->AppendBlock(ProfileKey.GetBuffer(0), ProfileKey.GetLength()); | 436 pTransformKey->AppendBlock(ProfileKey.GetBuffer(0), ProfileKey.GetLength()); |
440 if (!m_MapProfile.Lookup(ProfileKey, (FX_LPVOID&)pCache)) { | 437 if (!m_MapProfile.Lookup(ProfileKey, (FX_LPVOID&)pCache)) { |
441 pCache = FX_NEW CFX_IccProfileCache; | 438 pCache = new CFX_IccProfileCache; |
442 if (pCache == NULL) { | |
443 return NULL; | |
444 } | |
445 switch (pIccParam->dwProfileType) { | 439 switch (pIccParam->dwProfileType) { |
446 case Icc_PARAMTYPE_BUFFER: | 440 case Icc_PARAMTYPE_BUFFER: |
447 pCache->m_pProfile = cmsOpenProfileFromMem(pIccParam->pProfileDa
ta, pIccParam->dwProfileSize); | 441 pCache->m_pProfile = cmsOpenProfileFromMem(pIccParam->pProfileDa
ta, pIccParam->dwProfileSize); |
448 break; | 442 break; |
449 case Icc_PARAMTYPE_PARAM: | 443 case Icc_PARAMTYPE_PARAM: |
450 switch (pIccParam->ColorSpace) { | 444 switch (pIccParam->ColorSpace) { |
451 case IccCS_Rgb: | 445 case IccCS_Rgb: |
452 pCache->m_pProfile = cmsCreate_sRGBProfile(); | 446 pCache->m_pProfile = cmsCreate_sRGBProfile(); |
453 break; | 447 break; |
454 case IccCS_Gray: | 448 case IccCS_Gray: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); | 490 CFX_ByteStringC TransformKey(key.GetBuffer(), key.GetSize()); |
497 CFX_IccTransformCache* pTransformCache; | 491 CFX_IccTransformCache* pTransformCache; |
498 if (!m_MapTranform.Lookup(TransformKey, (FX_LPVOID&)pTransformCache)) { | 492 if (!m_MapTranform.Lookup(TransformKey, (FX_LPVOID&)pTransformCache)) { |
499 pCmm = FX_Alloc(CLcmsCmm, 1); | 493 pCmm = FX_Alloc(CLcmsCmm, 1); |
500 if (pCmm == NULL) { | 494 if (pCmm == NULL) { |
501 return NULL; | 495 return NULL; |
502 } | 496 } |
503 pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType); | 497 pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType); |
504 pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType); | 498 pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType); |
505 pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab; | 499 pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab; |
506 pTransformCache = FX_NEW CFX_IccTransformCache(pCmm); | 500 pTransformCache = new CFX_IccTransformCache(pCmm); |
507 if (pTransformCache == NULL) { | |
508 FX_Free(pCmm); | |
509 return NULL; | |
510 } | |
511 if (pProofProfile) { | 501 if (pProofProfile) { |
512 pTransformCache->m_pIccTransform = cmsCreateProofingTransform(pInput
Profile, dwInputProfileType, pOutputProfile, dwOutputProfileType, | 502 pTransformCache->m_pIccTransform = cmsCreateProofingTransform(pInput
Profile, dwInputProfileType, pOutputProfile, dwOutputProfileType, |
513 pProofProfile, dwIntent, dwPrfInt
ent, dwPrfFlag); | 503 pProofProfile, dwIntent, dwPrfInt
ent, dwPrfFlag); |
514 } else { | 504 } else { |
515 pTransformCache->m_pIccTransform = cmsCreateTransform(pInputProfile,
dwInputProfileType, pOutputProfile, dwOutputProfileType, | 505 pTransformCache->m_pIccTransform = cmsCreateTransform(pInputProfile,
dwInputProfileType, pOutputProfile, dwOutputProfileType, |
516 dwIntent, dwFlag); | 506 dwIntent, dwFlag); |
517 } | 507 } |
518 pCmm->m_hTransform = pTransformCache->m_pIccTransform; | 508 pCmm->m_hTransform = pTransformCache->m_pIccTransform; |
519 m_MapTranform.SetAt(TransformKey, pTransformCache); | 509 m_MapTranform.SetAt(TransformKey, pTransformCache); |
520 } else { | 510 } else { |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 FX_BYTE c1 = FXSYS_round(c * 255); | 1366 FX_BYTE c1 = FXSYS_round(c * 255); |
1377 FX_BYTE m1 = FXSYS_round(m * 255); | 1367 FX_BYTE m1 = FXSYS_round(m * 255); |
1378 FX_BYTE y1 = FXSYS_round(y * 255); | 1368 FX_BYTE y1 = FXSYS_round(y * 255); |
1379 FX_BYTE k1 = FXSYS_round(k * 255); | 1369 FX_BYTE k1 = FXSYS_round(k * 255); |
1380 FX_BYTE r, g, b; | 1370 FX_BYTE r, g, b; |
1381 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); | 1371 AdobeCMYK_to_sRGB1(c1, m1, y1, k1, r, g, b); |
1382 R = 1.0f * r / 255; | 1372 R = 1.0f * r / 255; |
1383 G = 1.0f * g / 255; | 1373 G = 1.0f * g / 255; |
1384 B = 1.0f * b / 255; | 1374 B = 1.0f * b / 255; |
1385 } | 1375 } |
OLD | NEW |