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/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../../../include/fxcodec/fx_codec.h" | 9 #include "../../../include/fxcodec/fx_codec.h" |
10 #include "pageint.h" | 10 #include "pageint.h" |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 636 } |
637 else if (m_nComponents == 3) { | 637 else if (m_nComponents == 3) { |
638 m_pAlterCS = GetStockCS(PDFCS_DEVICERGB); | 638 m_pAlterCS = GetStockCS(PDFCS_DEVICERGB); |
639 } | 639 } |
640 else if (m_nComponents == 4) { | 640 else if (m_nComponents == 4) { |
641 m_pAlterCS = GetStockCS(PDFCS_DEVICECMYK); | 641 m_pAlterCS = GetStockCS(PDFCS_DEVICECMYK); |
642 } | 642 } |
643 } | 643 } |
644 } | 644 } |
645 CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range")); | 645 CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range")); |
646 m_pRanges = FX_Alloc(FX_FLOAT, m_nComponents * 2); | 646 m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2); |
647 for (int i = 0; i < m_nComponents * 2; i ++) { | 647 for (int i = 0; i < m_nComponents * 2; i ++) { |
648 if (pRanges) { | 648 if (pRanges) { |
649 m_pRanges[i] = pRanges->GetNumber(i); | 649 m_pRanges[i] = pRanges->GetNumber(i); |
650 } else if (i % 2) { | 650 } else if (i % 2) { |
651 m_pRanges[i] = 1.0f; | 651 m_pRanges[i] = 1.0f; |
652 } else { | 652 } else { |
653 m_pRanges[i] = 0; | 653 m_pRanges[i] = 0; |
654 } | 654 } |
655 } | 655 } |
656 return TRUE; | 656 return TRUE; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 ReverseRGB(pDestBuf, pSrcBuf, pixels); | 708 ReverseRGB(pDestBuf, pSrcBuf, pixels); |
709 } else if (m_pProfile->m_pTransform) { | 709 } else if (m_pProfile->m_pTransform) { |
710 int nMaxColors = 1; | 710 int nMaxColors = 1; |
711 for (int i = 0; i < m_nComponents; i ++) { | 711 for (int i = 0; i < m_nComponents; i ++) { |
712 nMaxColors *= 52; | 712 nMaxColors *= 52; |
713 } | 713 } |
714 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2
) { | 714 if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2
) { |
715 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(m_pProfile-
>m_pTransform, pDestBuf, pSrcBuf, pixels); | 715 CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(m_pProfile-
>m_pTransform, pDestBuf, pSrcBuf, pixels); |
716 } else { | 716 } else { |
717 if (m_pCache == NULL) { | 717 if (m_pCache == NULL) { |
718 ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc(FX_BYTE, nMaxColor
s * 3); | 718 ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(FX_BYTE, nMaxCol
ors, 3); |
719 FX_LPBYTE temp_src = FX_Alloc(FX_BYTE, nMaxColors * m_nComponent
s); | 719 FX_LPBYTE temp_src = FX_Alloc2D(FX_BYTE, nMaxColors, m_nComponen
ts); |
720 FX_LPBYTE pSrc = temp_src; | 720 FX_LPBYTE pSrc = temp_src; |
721 for (int i = 0; i < nMaxColors; i ++) { | 721 for (int i = 0; i < nMaxColors; i ++) { |
722 FX_DWORD color = i; | 722 FX_DWORD color = i; |
723 FX_DWORD order = nMaxColors / 52; | 723 FX_DWORD order = nMaxColors / 52; |
724 for (int c = 0; c < m_nComponents; c ++) { | 724 for (int c = 0; c < m_nComponents; c ++) { |
725 *pSrc++ = (FX_BYTE)(color / order * 5); | 725 *pSrc++ = (FX_BYTE)(color / order * 5); |
726 color %= order; | 726 color %= order; |
727 order /= 52; | 727 order /= 52; |
728 } | 728 } |
729 } | 729 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 if (pBaseObj == m_pArray) { | 797 if (pBaseObj == m_pArray) { |
798 return FALSE; | 798 return FALSE; |
799 } | 799 } |
800 CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); | 800 CPDF_DocPageData* pDocPageData = pDoc->GetPageData(); |
801 m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL); | 801 m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL); |
802 if (m_pBaseCS == NULL) { | 802 if (m_pBaseCS == NULL) { |
803 return FALSE; | 803 return FALSE; |
804 } | 804 } |
805 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); | 805 m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); |
806 m_nBaseComponents = m_pBaseCS->CountComponents(); | 806 m_nBaseComponents = m_pBaseCS->CountComponents(); |
807 m_pCompMinMax = FX_Alloc(FX_FLOAT, m_nBaseComponents * 2); | 807 m_pCompMinMax = FX_Alloc2D(FX_FLOAT, m_nBaseComponents, 2); |
808 FX_FLOAT defvalue; | 808 FX_FLOAT defvalue; |
809 for (int i = 0; i < m_nBaseComponents; i ++) { | 809 for (int i = 0; i < m_nBaseComponents; i ++) { |
810 m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2], m_pCompMin
Max[i * 2 + 1]); | 810 m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2], m_pCompMin
Max[i * 2 + 1]); |
811 m_pCompMinMax[i * 2 + 1] -= m_pCompMinMax[i * 2]; | 811 m_pCompMinMax[i * 2 + 1] -= m_pCompMinMax[i * 2]; |
812 } | 812 } |
813 m_MaxIndex = pArray->GetInteger(2); | 813 m_MaxIndex = pArray->GetInteger(2); |
814 CPDF_Object* pTableObj = pArray->GetElementValue(3); | 814 CPDF_Object* pTableObj = pArray->GetElementValue(3); |
815 if (pTableObj == NULL) { | 815 if (pTableObj == NULL) { |
816 return FALSE; | 816 return FALSE; |
817 } | 817 } |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 PatternValue* pvalue = (PatternValue*)m_pBuffer; | 1448 PatternValue* pvalue = (PatternValue*)m_pBuffer; |
1449 return pvalue->m_nComps ? pvalue->m_Comps : NULL; | 1449 return pvalue->m_nComps ? pvalue->m_Comps : NULL; |
1450 } | 1450 } |
1451 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const | 1451 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const |
1452 { | 1452 { |
1453 if (m_pCS != other.m_pCS || m_pCS == NULL) { | 1453 if (m_pCS != other.m_pCS || m_pCS == NULL) { |
1454 return FALSE; | 1454 return FALSE; |
1455 } | 1455 } |
1456 return FXSYS_memcmp32(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; | 1456 return FXSYS_memcmp32(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; |
1457 } | 1457 } |
OLD | NEW |