OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdfapi/fpdf_page/include/cpdf_colorspace.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_page/pageint.h" | 9 #include "core/fpdfapi/fpdf_page/pageint.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 357 |
358 CPDF_Object* pFamilyObj = pArray->GetElementValue(0); | 358 CPDF_Object* pFamilyObj = pArray->GetElementValue(0); |
359 if (!pFamilyObj) | 359 if (!pFamilyObj) |
360 return nullptr; | 360 return nullptr; |
361 | 361 |
362 CFX_ByteString familyname = pFamilyObj->GetString(); | 362 CFX_ByteString familyname = pFamilyObj->GetString(); |
363 if (pArray->GetCount() == 1) | 363 if (pArray->GetCount() == 1) |
364 return ColorspaceFromName(familyname); | 364 return ColorspaceFromName(familyname); |
365 | 365 |
366 CPDF_ColorSpace* pCS = NULL; | 366 CPDF_ColorSpace* pCS = NULL; |
367 FX_DWORD id = familyname.GetID(); | 367 uint32_t id = familyname.GetID(); |
368 if (id == FXBSTR_ID('C', 'a', 'l', 'G')) { | 368 if (id == FXBSTR_ID('C', 'a', 'l', 'G')) { |
369 pCS = new CPDF_CalGray(pDoc); | 369 pCS = new CPDF_CalGray(pDoc); |
370 } else if (id == FXBSTR_ID('C', 'a', 'l', 'R')) { | 370 } else if (id == FXBSTR_ID('C', 'a', 'l', 'R')) { |
371 pCS = new CPDF_CalRGB(pDoc); | 371 pCS = new CPDF_CalRGB(pDoc); |
372 } else if (id == FXBSTR_ID('L', 'a', 'b', 0)) { | 372 } else if (id == FXBSTR_ID('L', 'a', 'b', 0)) { |
373 pCS = new CPDF_LabCS(pDoc); | 373 pCS = new CPDF_LabCS(pDoc); |
374 } else if (id == FXBSTR_ID('I', 'C', 'C', 'B')) { | 374 } else if (id == FXBSTR_ID('I', 'C', 'C', 'B')) { |
375 pCS = new CPDF_ICCBasedCS(pDoc); | 375 pCS = new CPDF_ICCBasedCS(pDoc); |
376 } else if (id == FXBSTR_ID('I', 'n', 'd', 'e') || | 376 } else if (id == FXBSTR_ID('I', 'n', 'd', 'e') || |
377 id == FXBSTR_ID('I', 0, 0, 0)) { | 377 id == FXBSTR_ID('I', 0, 0, 0)) { |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 } | 923 } |
924 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2) { | 924 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2) { |
925 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline( | 925 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline( |
926 m_pProfile->m_pTransform, pDestBuf, pSrcBuf, pixels); | 926 m_pProfile->m_pTransform, pDestBuf, pSrcBuf, pixels); |
927 } else { | 927 } else { |
928 if (!m_pCache) { | 928 if (!m_pCache) { |
929 ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3); | 929 ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3); |
930 uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents); | 930 uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents); |
931 uint8_t* pSrc = temp_src; | 931 uint8_t* pSrc = temp_src; |
932 for (int i = 0; i < nMaxColors; i++) { | 932 for (int i = 0; i < nMaxColors; i++) { |
933 FX_DWORD color = i; | 933 uint32_t color = i; |
934 FX_DWORD order = nMaxColors / 52; | 934 uint32_t order = nMaxColors / 52; |
935 for (int c = 0; c < m_nComponents; c++) { | 935 for (int c = 0; c < m_nComponents; c++) { |
936 *pSrc++ = (uint8_t)(color / order * 5); | 936 *pSrc++ = (uint8_t)(color / order * 5); |
937 color %= order; | 937 color %= order; |
938 order /= 52; | 938 order /= 52; |
939 } | 939 } |
940 } | 940 } |
941 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline( | 941 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline( |
942 m_pProfile->m_pTransform, m_pCache, temp_src, nMaxColors); | 942 m_pProfile->m_pTransform, m_pCache, temp_src, nMaxColors); |
943 FX_Free(temp_src); | 943 FX_Free(temp_src); |
944 } | 944 } |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 } | 1244 } |
1245 return m_pAltCS->GetRGB(results, R, G, B); | 1245 return m_pAltCS->GetRGB(results, R, G, B); |
1246 } | 1246 } |
1247 | 1247 |
1248 void CPDF_DeviceNCS::EnableStdConversion(FX_BOOL bEnabled) { | 1248 void CPDF_DeviceNCS::EnableStdConversion(FX_BOOL bEnabled) { |
1249 CPDF_ColorSpace::EnableStdConversion(bEnabled); | 1249 CPDF_ColorSpace::EnableStdConversion(bEnabled); |
1250 if (m_pAltCS) { | 1250 if (m_pAltCS) { |
1251 m_pAltCS->EnableStdConversion(bEnabled); | 1251 m_pAltCS->EnableStdConversion(bEnabled); |
1252 } | 1252 } |
1253 } | 1253 } |
OLD | NEW |