| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 { | 274 { |
| 275 m_Family = PDFCS_CALGRAY; | 275 m_Family = PDFCS_CALGRAY; |
| 276 m_nComponents = 1; | 276 m_nComponents = 1; |
| 277 } | 277 } |
| 278 FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) | 278 FX_BOOL CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) |
| 279 { | 279 { |
| 280 CPDF_Dictionary* pDict = pArray->GetDict(1); | 280 CPDF_Dictionary* pDict = pArray->GetDict(1); |
| 281 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); | 281 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); |
| 282 int i; | 282 int i; |
| 283 for (i = 0; i < 3; i ++) { | 283 for (i = 0; i < 3; i ++) { |
| 284 m_WhitePoint[i] = pParam->GetNumber(i); | 284 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0; |
| 285 } | 285 } |
| 286 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); | 286 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); |
| 287 for (i = 0; i < 3; i ++) { | 287 for (i = 0; i < 3; i ++) { |
| 288 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; | 288 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; |
| 289 } | 289 } |
| 290 m_Gamma = pDict->GetNumber(FX_BSTRC("Gamma")); | 290 m_Gamma = pDict->GetNumber(FX_BSTRC("Gamma")); |
| 291 if (m_Gamma == 0) { | 291 if (m_Gamma == 0) { |
| 292 m_Gamma = 1.0f; | 292 m_Gamma = 1.0f; |
| 293 } | 293 } |
| 294 return TRUE; | 294 return TRUE; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 { | 333 { |
| 334 m_Family = PDFCS_CALRGB; | 334 m_Family = PDFCS_CALRGB; |
| 335 m_nComponents = 3; | 335 m_nComponents = 3; |
| 336 } | 336 } |
| 337 FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) | 337 FX_BOOL CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) |
| 338 { | 338 { |
| 339 CPDF_Dictionary* pDict = pArray->GetDict(1); | 339 CPDF_Dictionary* pDict = pArray->GetDict(1); |
| 340 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); | 340 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); |
| 341 int i; | 341 int i; |
| 342 for (i = 0; i < 3; i ++) { | 342 for (i = 0; i < 3; i ++) { |
| 343 m_WhitePoint[i] = pParam->GetNumber(i); | 343 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0; |
| 344 } | 344 } |
| 345 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); | 345 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); |
| 346 for (i = 0; i < 3; i ++) { | 346 for (i = 0; i < 3; i ++) { |
| 347 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; | 347 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; |
| 348 } | 348 } |
| 349 pParam = pDict->GetArray(FX_BSTRC("Gamma")); | 349 pParam = pDict->GetArray(FX_BSTRC("Gamma")); |
| 350 if (pParam) { | 350 if (pParam) { |
| 351 m_bGamma = TRUE; | 351 m_bGamma = TRUE; |
| 352 for (i = 0; i < 3; i ++) { | 352 for (i = 0; i < 3; i ++) { |
| 353 m_Gamma[i] = pParam->GetNumber(i); | 353 m_Gamma[i] = pParam->GetNumber(i); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 FX_FLOAT m_WhitePoint[3]; | 431 FX_FLOAT m_WhitePoint[3]; |
| 432 FX_FLOAT m_BlackPoint[3]; | 432 FX_FLOAT m_BlackPoint[3]; |
| 433 FX_FLOAT m_Ranges[4]; | 433 FX_FLOAT m_Ranges[4]; |
| 434 }; | 434 }; |
| 435 FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) | 435 FX_BOOL CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) |
| 436 { | 436 { |
| 437 CPDF_Dictionary* pDict = pArray->GetDict(1); | 437 CPDF_Dictionary* pDict = pArray->GetDict(1); |
| 438 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); | 438 CPDF_Array* pParam = pDict->GetArray(FX_BSTRC("WhitePoint")); |
| 439 int i; | 439 int i; |
| 440 for (i = 0; i < 3; i ++) { | 440 for (i = 0; i < 3; i ++) { |
| 441 m_WhitePoint[i] = pParam->GetNumber(i); | 441 m_WhitePoint[i] = pParam ? pParam->GetNumber(i) : 0; |
| 442 } | 442 } |
| 443 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); | 443 pParam = pDict->GetArray(FX_BSTRC("BlackPoint")); |
| 444 for (i = 0; i < 3; i ++) { | 444 for (i = 0; i < 3; i ++) { |
| 445 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; | 445 m_BlackPoint[i] = pParam ? pParam->GetNumber(i) : 0; |
| 446 } | 446 } |
| 447 pParam = pDict->GetArray(FX_BSTRC("Range")); | 447 pParam = pDict->GetArray(FX_BSTRC("Range")); |
| 448 const FX_FLOAT def_ranges[4] = { -100 * 1.0f, 100 * 1.0f, -100 * 1.0f, 100 *
1.0f}; | 448 const FX_FLOAT def_ranges[4] = { -100 * 1.0f, 100 * 1.0f, -100 * 1.0f, 100 *
1.0f}; |
| 449 for (i = 0; i < 4; i ++) { | 449 for (i = 0; i < 4; i ++) { |
| 450 m_Ranges[i] = pParam ? pParam->GetNumber(i) : def_ranges[i]; | 450 m_Ranges[i] = pParam ? pParam->GetNumber(i) : def_ranges[i]; |
| 451 } | 451 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 if (m_pProfile && m_pDocument) { | 573 if (m_pProfile && m_pDocument) { |
| 574 m_pDocument->GetPageData()->ReleaseIccProfile(NULL, m_pProfile); | 574 m_pDocument->GetPageData()->ReleaseIccProfile(NULL, m_pProfile); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) | 577 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) |
| 578 { | 578 { |
| 579 CPDF_Stream* pStream = pArray->GetStream(1); | 579 CPDF_Stream* pStream = pArray->GetStream(1); |
| 580 if (pStream == NULL) { | 580 if (pStream == NULL) { |
| 581 return FALSE; | 581 return FALSE; |
| 582 } | 582 } |
| 583 m_nComponents = pStream->GetDict()->GetInteger(FX_BSTRC("N")); | 583 CPDF_Dictionary* pDict = pStream->GetDict(); |
| 584 m_nComponents = pDict ? pDict->GetInteger(FX_BSTRC("N")) : 0; |
| 584 if (m_nComponents < 0 || m_nComponents > (1 << 16)) { | 585 if (m_nComponents < 0 || m_nComponents > (1 << 16)) { |
| 585 return FALSE; | 586 return FALSE; |
| 586 } | 587 } |
| 587 CPDF_Array* pRanges = pStream->GetDict()->GetArray(FX_BSTRC("Range")); | 588 CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range")); |
| 588 m_pRanges = FX_Alloc(FX_FLOAT, m_nComponents * 2); | 589 m_pRanges = FX_Alloc(FX_FLOAT, m_nComponents * 2); |
| 589 for (int i = 0; i < m_nComponents * 2; i ++) { | 590 for (int i = 0; i < m_nComponents * 2; i ++) { |
| 590 if (pRanges) { | 591 if (pRanges) { |
| 591 m_pRanges[i] = pRanges->GetNumber(i); | 592 m_pRanges[i] = pRanges->GetNumber(i); |
| 592 } else if (i % 2) { | 593 } else if (i % 2) { |
| 593 m_pRanges[i] = 1.0f; | 594 m_pRanges[i] = 1.0f; |
| 594 } else { | 595 } else { |
| 595 m_pRanges[i] = 0; | 596 m_pRanges[i] = 0; |
| 596 } | 597 } |
| 597 } | 598 } |
| 598 m_pProfile = pDoc->LoadIccProfile(pStream, m_nComponents); | 599 m_pProfile = pDoc->LoadIccProfile(pStream, m_nComponents); |
| 599 if (!m_pProfile) { | 600 if (!m_pProfile) { |
| 600 return FALSE; | 601 return FALSE; |
| 601 } | 602 } |
| 602 if (m_pProfile->m_pTransform == NULL) { | 603 if (m_pProfile->m_pTransform == NULL) { |
| 603 CPDF_Object* pAlterCSObj = pStream->GetDict()->GetElementValue(FX_BSTRC(
"Alternate")); | 604 CPDF_Object* pAlterCSObj = pDict ? pDict->GetElementValue(FX_BSTRC("Alte
rnate")) : NULL; |
| 604 if (pAlterCSObj) { | 605 if (pAlterCSObj) { |
| 605 CPDF_ColorSpace* alter_cs = CPDF_ColorSpace::Load(pDoc, pAlterCSObj)
; | 606 CPDF_ColorSpace* alter_cs = CPDF_ColorSpace::Load(pDoc, pAlterCSObj)
; |
| 606 if (alter_cs) { | 607 if (alter_cs) { |
| 607 if (alter_cs->CountComponents() > m_nComponents) { | 608 if (alter_cs->CountComponents() > m_nComponents) { |
| 608 alter_cs->ReleaseCS(); | 609 alter_cs->ReleaseCS(); |
| 609 } else { | 610 } else { |
| 610 m_pAlterCS = alter_cs; | 611 m_pAlterCS = alter_cs; |
| 611 m_bOwn = TRUE; | 612 m_bOwn = TRUE; |
| 612 } | 613 } |
| 613 } | 614 } |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 if (pObj->GetType() == PDFOBJ_STREAM) { | 1073 if (pObj->GetType() == PDFOBJ_STREAM) { |
| 1073 CPDF_Dictionary *pDict = ((CPDF_Stream *)pObj)->GetDict(); | 1074 CPDF_Dictionary *pDict = ((CPDF_Stream *)pObj)->GetDict(); |
| 1074 if (!pDict) { | 1075 if (!pDict) { |
| 1075 return NULL; | 1076 return NULL; |
| 1076 } | 1077 } |
| 1077 CPDF_ColorSpace *pRet = NULL; | 1078 CPDF_ColorSpace *pRet = NULL; |
| 1078 FX_POSITION pos = pDict->GetStartPos(); | 1079 FX_POSITION pos = pDict->GetStartPos(); |
| 1079 while (pos) { | 1080 while (pos) { |
| 1080 CFX_ByteString bsKey; | 1081 CFX_ByteString bsKey; |
| 1081 CPDF_Object *pValue = pDict->GetNextElement(pos, bsKey); | 1082 CPDF_Object *pValue = pDict->GetNextElement(pos, bsKey); |
| 1082 if (pValue->GetType() == PDFOBJ_NAME) { | 1083 if (pValue && pValue->GetType() == PDFOBJ_NAME) { |
| 1083 pRet = _CSFromName(pValue->GetString()); | 1084 pRet = _CSFromName(pValue->GetString()); |
| 1084 } | 1085 } |
| 1085 if (pRet) { | 1086 if (pRet) { |
| 1086 return pRet; | 1087 return pRet; |
| 1087 } | 1088 } |
| 1088 } | 1089 } |
| 1089 return NULL; | 1090 return NULL; |
| 1090 } | 1091 } |
| 1091 if (pObj->GetType() != PDFOBJ_ARRAY) { | 1092 if (pObj->GetType() != PDFOBJ_ARRAY) { |
| 1092 return NULL; | 1093 return NULL; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 PatternValue* pvalue = (PatternValue*)m_pBuffer; | 1394 PatternValue* pvalue = (PatternValue*)m_pBuffer; |
| 1394 return pvalue->m_nComps ? pvalue->m_Comps : NULL; | 1395 return pvalue->m_nComps ? pvalue->m_Comps : NULL; |
| 1395 } | 1396 } |
| 1396 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const | 1397 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const |
| 1397 { | 1398 { |
| 1398 if (m_pCS != other.m_pCS || m_pCS == NULL) { | 1399 if (m_pCS != other.m_pCS || m_pCS == NULL) { |
| 1399 return FALSE; | 1400 return FALSE; |
| 1400 } | 1401 } |
| 1401 return FXSYS_memcmp32(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; | 1402 return FXSYS_memcmp32(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0; |
| 1402 } | 1403 } |
| OLD | NEW |