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/fxcodec/include/fx_codec.h" | 8 #include "core/fxcodec/include/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 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return NULL; | 244 return NULL; |
245 } | 245 } |
246 cmsToneCurve* curve = cmsBuildGamma(NULL, gamma); | 246 cmsToneCurve* curve = cmsBuildGamma(NULL, gamma); |
247 if (!curve) { | 247 if (!curve) { |
248 return NULL; | 248 return NULL; |
249 } | 249 } |
250 void* profile = cmsCreateGrayProfile(D50, curve); | 250 void* profile = cmsCreateGrayProfile(D50, curve); |
251 cmsFreeToneCurve(curve); | 251 cmsFreeToneCurve(curve); |
252 return profile; | 252 return profile; |
253 } | 253 } |
254 ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) { | 254 CCodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) { |
255 if (!pProfile) { | 255 if (!pProfile) { |
256 return ICodec_IccModule::IccCS_Unknown; | 256 return CCodec_IccModule::IccCS_Unknown; |
257 } | 257 } |
258 switch (cmsGetColorSpace(pProfile)) { | 258 switch (cmsGetColorSpace(pProfile)) { |
259 case cmsSigXYZData: | 259 case cmsSigXYZData: |
260 return ICodec_IccModule::IccCS_XYZ; | 260 return CCodec_IccModule::IccCS_XYZ; |
261 case cmsSigLabData: | 261 case cmsSigLabData: |
262 return ICodec_IccModule::IccCS_Lab; | 262 return CCodec_IccModule::IccCS_Lab; |
263 case cmsSigLuvData: | 263 case cmsSigLuvData: |
264 return ICodec_IccModule::IccCS_Luv; | 264 return CCodec_IccModule::IccCS_Luv; |
265 case cmsSigYCbCrData: | 265 case cmsSigYCbCrData: |
266 return ICodec_IccModule::IccCS_YCbCr; | 266 return CCodec_IccModule::IccCS_YCbCr; |
267 case cmsSigYxyData: | 267 case cmsSigYxyData: |
268 return ICodec_IccModule::IccCS_Yxy; | 268 return CCodec_IccModule::IccCS_Yxy; |
269 case cmsSigRgbData: | 269 case cmsSigRgbData: |
270 return ICodec_IccModule::IccCS_Rgb; | 270 return CCodec_IccModule::IccCS_Rgb; |
271 case cmsSigGrayData: | 271 case cmsSigGrayData: |
272 return ICodec_IccModule::IccCS_Gray; | 272 return CCodec_IccModule::IccCS_Gray; |
273 case cmsSigHsvData: | 273 case cmsSigHsvData: |
274 return ICodec_IccModule::IccCS_Hsv; | 274 return CCodec_IccModule::IccCS_Hsv; |
275 case cmsSigHlsData: | 275 case cmsSigHlsData: |
276 return ICodec_IccModule::IccCS_Hls; | 276 return CCodec_IccModule::IccCS_Hls; |
277 case cmsSigCmykData: | 277 case cmsSigCmykData: |
278 return ICodec_IccModule::IccCS_Cmyk; | 278 return CCodec_IccModule::IccCS_Cmyk; |
279 case cmsSigCmyData: | 279 case cmsSigCmyData: |
280 return ICodec_IccModule::IccCS_Cmy; | 280 return CCodec_IccModule::IccCS_Cmy; |
281 default: | 281 default: |
282 return ICodec_IccModule::IccCS_Unknown; | 282 return CCodec_IccModule::IccCS_Unknown; |
283 } | 283 } |
284 } | 284 } |
285 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( | 285 CCodec_IccModule::IccCS CCodec_IccModule::GetProfileCS( |
286 const uint8_t* pProfileData, | 286 const uint8_t* pProfileData, |
287 uint32_t dwProfileSize) { | 287 uint32_t dwProfileSize) { |
288 ICodec_IccModule::IccCS cs; | 288 CCodec_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 CCodec_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 CCodec_IccModule::IccCS cs; |
305 uint32_t dwSize = (uint32_t)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 uint32_t TransferProfileType(void* pProfile, uint32_t 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) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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<<(uint32_t i); | 403 CFX_ByteStringKey& operator<<(uint32_t i); |
404 }; | 404 }; |
405 CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) { | 405 CFX_ByteStringKey& CFX_ByteStringKey::operator<<(uint32_t i) { |
406 AppendBlock(&i, sizeof(uint32_t)); | 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(CCodec_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]; |
417 switch (pIccParam->dwProfileType) { | 417 switch (pIccParam->dwProfileType) { |
418 case Icc_PARAMTYPE_NONE: | 418 case Icc_PARAMTYPE_NONE: |
419 return NULL; | 419 return NULL; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 break; | 462 break; |
463 } | 463 } |
464 m_MapProfile[ProfileKey] = pCache; | 464 m_MapProfile[ProfileKey] = pCache; |
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 CCodec_IccModule::IccParam* pInputParam, |
473 ICodec_IccModule::IccParam* pOutputParam, | 473 CCodec_IccModule::IccParam* pOutputParam, |
474 ICodec_IccModule::IccParam* pProofParam, | 474 CCodec_IccModule::IccParam* pProofParam, |
475 uint32_t dwIntent, | 475 uint32_t dwIntent, |
476 uint32_t dwFlag, | 476 uint32_t dwFlag, |
477 uint32_t dwPrfIntent, | 477 uint32_t dwPrfIntent, |
478 uint32_t 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; |
(...skipping 1492 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 |