| 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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 FX_BOOL bLoadMask) { | 148 FX_BOOL bLoadMask) { |
| 149 if (!pStream) { | 149 if (!pStream) { |
| 150 return FALSE; | 150 return FALSE; |
| 151 } | 151 } |
| 152 m_pDocument = pDoc; | 152 m_pDocument = pDoc; |
| 153 m_pDict = pStream->GetDict(); | 153 m_pDict = pStream->GetDict(); |
| 154 if (!m_pDict) { | 154 if (!m_pDict) { |
| 155 return FALSE; | 155 return FALSE; |
| 156 } | 156 } |
| 157 m_pStream = pStream; | 157 m_pStream = pStream; |
| 158 m_Width = m_pDict->GetIntegerBy("Width"); | 158 m_Width = m_pDict->GetIntegerFor("Width"); |
| 159 m_Height = m_pDict->GetIntegerBy("Height"); | 159 m_Height = m_pDict->GetIntegerFor("Height"); |
| 160 if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || | 160 if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || |
| 161 m_Height > kMaxImageDimension) { | 161 m_Height > kMaxImageDimension) { |
| 162 return FALSE; | 162 return FALSE; |
| 163 } | 163 } |
| 164 m_GroupFamily = GroupFamily; | 164 m_GroupFamily = GroupFamily; |
| 165 m_bLoadMask = bLoadMask; | 165 m_bLoadMask = bLoadMask; |
| 166 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? nullptr : pFormResources, | 166 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? nullptr : pFormResources, |
| 167 pPageResources)) { | 167 pPageResources)) { |
| 168 return FALSE; | 168 return FALSE; |
| 169 } | 169 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 uint32_t GroupFamily, | 270 uint32_t GroupFamily, |
| 271 FX_BOOL bLoadMask) { | 271 FX_BOOL bLoadMask) { |
| 272 if (!pStream) { | 272 if (!pStream) { |
| 273 return 0; | 273 return 0; |
| 274 } | 274 } |
| 275 m_pDocument = pDoc; | 275 m_pDocument = pDoc; |
| 276 m_pDict = pStream->GetDict(); | 276 m_pDict = pStream->GetDict(); |
| 277 m_pStream = pStream; | 277 m_pStream = pStream; |
| 278 m_bStdCS = bStdCS; | 278 m_bStdCS = bStdCS; |
| 279 m_bHasMask = bHasMask; | 279 m_bHasMask = bHasMask; |
| 280 m_Width = m_pDict->GetIntegerBy("Width"); | 280 m_Width = m_pDict->GetIntegerFor("Width"); |
| 281 m_Height = m_pDict->GetIntegerBy("Height"); | 281 m_Height = m_pDict->GetIntegerFor("Height"); |
| 282 if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || | 282 if (m_Width <= 0 || m_Height <= 0 || m_Width > kMaxImageDimension || |
| 283 m_Height > kMaxImageDimension) { | 283 m_Height > kMaxImageDimension) { |
| 284 return 0; | 284 return 0; |
| 285 } | 285 } |
| 286 m_GroupFamily = GroupFamily; | 286 m_GroupFamily = GroupFamily; |
| 287 m_bLoadMask = bLoadMask; | 287 m_bLoadMask = bLoadMask; |
| 288 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? nullptr : pFormResources, | 288 if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? nullptr : pFormResources, |
| 289 pPageResources)) { | 289 pPageResources)) { |
| 290 return 0; | 290 return 0; |
| 291 } | 291 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 if (m_Status == 1) { | 335 if (m_Status == 1) { |
| 336 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); | 336 const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder(); |
| 337 if (decoder == "JPXDecode") { | 337 if (decoder == "JPXDecode") { |
| 338 return 0; | 338 return 0; |
| 339 } | 339 } |
| 340 CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module(); | 340 CCodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module(); |
| 341 if (!m_pJbig2Context) { | 341 if (!m_pJbig2Context) { |
| 342 m_pJbig2Context.reset(new CCodec_Jbig2Context()); | 342 m_pJbig2Context.reset(new CCodec_Jbig2Context()); |
| 343 if (m_pStreamAcc->GetImageParam()) { | 343 if (m_pStreamAcc->GetImageParam()) { |
| 344 CPDF_Stream* pGlobals = | 344 CPDF_Stream* pGlobals = |
| 345 m_pStreamAcc->GetImageParam()->GetStreamBy("JBIG2Globals"); | 345 m_pStreamAcc->GetImageParam()->GetStreamFor("JBIG2Globals"); |
| 346 if (pGlobals) { | 346 if (pGlobals) { |
| 347 m_pGlobalStream.reset(new CPDF_StreamAcc); | 347 m_pGlobalStream.reset(new CPDF_StreamAcc); |
| 348 m_pGlobalStream->LoadAllData(pGlobals, FALSE); | 348 m_pGlobalStream->LoadAllData(pGlobals, FALSE); |
| 349 } | 349 } |
| 350 } | 350 } |
| 351 ret = pJbig2Module->StartDecode( | 351 ret = pJbig2Module->StartDecode( |
| 352 m_pJbig2Context.get(), m_pDocument->CodecContext(), m_Width, m_Height, | 352 m_pJbig2Context.get(), m_pDocument->CodecContext(), m_Width, m_Height, |
| 353 m_pStreamAcc.get(), m_pGlobalStream.get(), | 353 m_pStreamAcc.get(), m_pGlobalStream.get(), |
| 354 m_pCachedBitmap->GetBuffer(), m_pCachedBitmap->GetPitch(), pPause); | 354 m_pCachedBitmap->GetBuffer(), m_pCachedBitmap->GetPitch(), pPause); |
| 355 if (ret < 0) { | 355 if (ret < 0) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 return ret1; | 398 return ret1; |
| 399 } | 399 } |
| 400 if (m_Status == 2) { | 400 if (m_Status == 2) { |
| 401 return ContinueLoadMaskDIB(pPause); | 401 return ContinueLoadMaskDIB(pPause); |
| 402 } | 402 } |
| 403 return 0; | 403 return 0; |
| 404 } | 404 } |
| 405 | 405 |
| 406 bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, | 406 bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources, |
| 407 const CPDF_Dictionary* pPageResources) { | 407 const CPDF_Dictionary* pPageResources) { |
| 408 m_bpc_orig = m_pDict->GetIntegerBy("BitsPerComponent"); | 408 m_bpc_orig = m_pDict->GetIntegerFor("BitsPerComponent"); |
| 409 if (m_pDict->GetIntegerBy("ImageMask")) | 409 if (m_pDict->GetIntegerFor("ImageMask")) |
| 410 m_bImageMask = TRUE; | 410 m_bImageMask = TRUE; |
| 411 | 411 |
| 412 if (m_bImageMask || !m_pDict->KeyExist("ColorSpace")) { | 412 if (m_bImageMask || !m_pDict->KeyExist("ColorSpace")) { |
| 413 if (!m_bImageMask) { | 413 if (!m_bImageMask) { |
| 414 CPDF_Object* pFilter = m_pDict->GetDirectObjectBy("Filter"); | 414 CPDF_Object* pFilter = m_pDict->GetDirectObjectFor("Filter"); |
| 415 if (pFilter) { | 415 if (pFilter) { |
| 416 CFX_ByteString filter; | 416 CFX_ByteString filter; |
| 417 if (pFilter->IsName()) { | 417 if (pFilter->IsName()) { |
| 418 filter = pFilter->GetString(); | 418 filter = pFilter->GetString(); |
| 419 } else if (CPDF_Array* pArray = pFilter->AsArray()) { | 419 } else if (CPDF_Array* pArray = pFilter->AsArray()) { |
| 420 filter = pArray->GetStringAt(pArray->GetCount() - 1); | 420 filter = pArray->GetStringAt(pArray->GetCount() - 1); |
| 421 } | 421 } |
| 422 | 422 |
| 423 if (filter == "JPXDecode") { | 423 if (filter == "JPXDecode") { |
| 424 m_bDoBpcCheck = FALSE; | 424 m_bDoBpcCheck = FALSE; |
| 425 return true; | 425 return true; |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 m_bImageMask = TRUE; | 429 m_bImageMask = TRUE; |
| 430 m_bpc = m_nComponents = 1; | 430 m_bpc = m_nComponents = 1; |
| 431 CPDF_Array* pDecode = m_pDict->GetArrayBy("Decode"); | 431 CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode"); |
| 432 m_bDefaultDecode = !pDecode || !pDecode->GetIntegerAt(0); | 432 m_bDefaultDecode = !pDecode || !pDecode->GetIntegerAt(0); |
| 433 return true; | 433 return true; |
| 434 } | 434 } |
| 435 | 435 |
| 436 CPDF_Object* pCSObj = m_pDict->GetDirectObjectBy("ColorSpace"); | 436 CPDF_Object* pCSObj = m_pDict->GetDirectObjectFor("ColorSpace"); |
| 437 if (!pCSObj) | 437 if (!pCSObj) |
| 438 return false; | 438 return false; |
| 439 | 439 |
| 440 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); | 440 CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData(); |
| 441 if (pFormResources) | 441 if (pFormResources) |
| 442 m_pColorSpace = pDocPageData->GetColorSpace(pCSObj, pFormResources); | 442 m_pColorSpace = pDocPageData->GetColorSpace(pCSObj, pFormResources); |
| 443 if (!m_pColorSpace) | 443 if (!m_pColorSpace) |
| 444 m_pColorSpace = pDocPageData->GetColorSpace(pCSObj, pPageResources); | 444 m_pColorSpace = pDocPageData->GetColorSpace(pCSObj, pPageResources); |
| 445 if (!m_pColorSpace) | 445 if (!m_pColorSpace) |
| 446 return false; | 446 return false; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 462 return !!m_pCompData; | 462 return !!m_pCompData; |
| 463 } | 463 } |
| 464 | 464 |
| 465 DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, | 465 DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode, |
| 466 FX_BOOL& bColorKey) { | 466 FX_BOOL& bColorKey) { |
| 467 if (!m_pColorSpace) { | 467 if (!m_pColorSpace) { |
| 468 return nullptr; | 468 return nullptr; |
| 469 } | 469 } |
| 470 DIB_COMP_DATA* pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents); | 470 DIB_COMP_DATA* pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents); |
| 471 int max_data = (1 << m_bpc) - 1; | 471 int max_data = (1 << m_bpc) - 1; |
| 472 CPDF_Array* pDecode = m_pDict->GetArrayBy("Decode"); | 472 CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode"); |
| 473 if (pDecode) { | 473 if (pDecode) { |
| 474 for (uint32_t i = 0; i < m_nComponents; i++) { | 474 for (uint32_t i = 0; i < m_nComponents; i++) { |
| 475 pCompData[i].m_DecodeMin = pDecode->GetNumberAt(i * 2); | 475 pCompData[i].m_DecodeMin = pDecode->GetNumberAt(i * 2); |
| 476 FX_FLOAT max = pDecode->GetNumberAt(i * 2 + 1); | 476 FX_FLOAT max = pDecode->GetNumberAt(i * 2 + 1); |
| 477 pCompData[i].m_DecodeStep = (max - pCompData[i].m_DecodeMin) / max_data; | 477 pCompData[i].m_DecodeStep = (max - pCompData[i].m_DecodeMin) / max_data; |
| 478 FX_FLOAT def_value; | 478 FX_FLOAT def_value; |
| 479 FX_FLOAT def_min; | 479 FX_FLOAT def_min; |
| 480 FX_FLOAT def_max; | 480 FX_FLOAT def_max; |
| 481 m_pColorSpace->GetDefaultValue(i, def_value, def_min, def_max); | 481 m_pColorSpace->GetDefaultValue(i, def_value, def_min, def_max); |
| 482 if (m_Family == PDFCS_INDEXED) { | 482 if (m_Family == PDFCS_INDEXED) { |
| 483 def_max = max_data; | 483 def_max = max_data; |
| 484 } | 484 } |
| 485 if (def_min != pCompData[i].m_DecodeMin || def_max != max) { | 485 if (def_min != pCompData[i].m_DecodeMin || def_max != max) { |
| 486 bDefaultDecode = FALSE; | 486 bDefaultDecode = FALSE; |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 } else { | 489 } else { |
| 490 for (uint32_t i = 0; i < m_nComponents; i++) { | 490 for (uint32_t i = 0; i < m_nComponents; i++) { |
| 491 FX_FLOAT def_value; | 491 FX_FLOAT def_value; |
| 492 m_pColorSpace->GetDefaultValue(i, def_value, pCompData[i].m_DecodeMin, | 492 m_pColorSpace->GetDefaultValue(i, def_value, pCompData[i].m_DecodeMin, |
| 493 pCompData[i].m_DecodeStep); | 493 pCompData[i].m_DecodeStep); |
| 494 if (m_Family == PDFCS_INDEXED) { | 494 if (m_Family == PDFCS_INDEXED) { |
| 495 pCompData[i].m_DecodeStep = max_data; | 495 pCompData[i].m_DecodeStep = max_data; |
| 496 } | 496 } |
| 497 pCompData[i].m_DecodeStep = | 497 pCompData[i].m_DecodeStep = |
| 498 (pCompData[i].m_DecodeStep - pCompData[i].m_DecodeMin) / max_data; | 498 (pCompData[i].m_DecodeStep - pCompData[i].m_DecodeMin) / max_data; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 if (!m_pDict->KeyExist("SMask")) { | 501 if (!m_pDict->KeyExist("SMask")) { |
| 502 CPDF_Object* pMask = m_pDict->GetDirectObjectBy("Mask"); | 502 CPDF_Object* pMask = m_pDict->GetDirectObjectFor("Mask"); |
| 503 if (!pMask) { | 503 if (!pMask) { |
| 504 return pCompData; | 504 return pCompData; |
| 505 } | 505 } |
| 506 if (CPDF_Array* pArray = pMask->AsArray()) { | 506 if (CPDF_Array* pArray = pMask->AsArray()) { |
| 507 if (pArray->GetCount() >= m_nComponents * 2) { | 507 if (pArray->GetCount() >= m_nComponents * 2) { |
| 508 for (uint32_t i = 0; i < m_nComponents; i++) { | 508 for (uint32_t i = 0; i < m_nComponents; i++) { |
| 509 int min_num = pArray->GetIntegerAt(i * 2); | 509 int min_num = pArray->GetIntegerAt(i * 2); |
| 510 int max_num = pArray->GetIntegerAt(i * 2 + 1); | 510 int max_num = pArray->GetIntegerAt(i * 2 + 1); |
| 511 pCompData[i].m_ColorKeyMin = std::max(min_num, 0); | 511 pCompData[i].m_ColorKeyMin = std::max(min_num, 0); |
| 512 pCompData[i].m_ColorKeyMax = std::min(max_num, max_data); | 512 pCompData[i].m_ColorKeyMax = std::min(max_num, max_data); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 544 } |
| 545 const uint8_t* src_data = m_pStreamAcc->GetData(); | 545 const uint8_t* src_data = m_pStreamAcc->GetData(); |
| 546 uint32_t src_size = m_pStreamAcc->GetSize(); | 546 uint32_t src_size = m_pStreamAcc->GetSize(); |
| 547 const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); | 547 const CPDF_Dictionary* pParams = m_pStreamAcc->GetImageParam(); |
| 548 if (decoder == "CCITTFaxDecode") { | 548 if (decoder == "CCITTFaxDecode") { |
| 549 m_pDecoder.reset(FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, | 549 m_pDecoder.reset(FPDFAPI_CreateFaxDecoder(src_data, src_size, m_Width, |
| 550 m_Height, pParams)); | 550 m_Height, pParams)); |
| 551 } else if (decoder == "DCTDecode") { | 551 } else if (decoder == "DCTDecode") { |
| 552 m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( | 552 m_pDecoder.reset(CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder( |
| 553 src_data, src_size, m_Width, m_Height, m_nComponents, | 553 src_data, src_size, m_Width, m_Height, m_nComponents, |
| 554 pParams ? pParams->GetIntegerBy("ColorTransform", 1) : 1)); | 554 pParams ? pParams->GetIntegerFor("ColorTransform", 1) : 1)); |
| 555 if (!m_pDecoder) { | 555 if (!m_pDecoder) { |
| 556 bool bTransform = false; | 556 bool bTransform = false; |
| 557 int comps; | 557 int comps; |
| 558 int bpc; | 558 int bpc; |
| 559 CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); | 559 CCodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); |
| 560 if (pJpegModule->LoadInfo(src_data, src_size, &m_Width, &m_Height, &comps, | 560 if (pJpegModule->LoadInfo(src_data, src_size, &m_Width, &m_Height, &comps, |
| 561 &bpc, &bTransform)) { | 561 &bpc, &bTransform)) { |
| 562 if (m_nComponents != static_cast<uint32_t>(comps)) { | 562 if (m_nComponents != static_cast<uint32_t>(comps)) { |
| 563 FX_Free(m_pCompData); | 563 FX_Free(m_pCompData); |
| 564 m_pCompData = nullptr; | 564 m_pCompData = nullptr; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 *scanline = (*scanline) >> scale; | 693 *scanline = (*scanline) >> scale; |
| 694 ++scanline; | 694 ++scanline; |
| 695 } | 695 } |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 m_bpc = 8; | 698 m_bpc = 8; |
| 699 } | 699 } |
| 700 | 700 |
| 701 CPDF_DIBSource* CPDF_DIBSource::LoadMask(uint32_t& MatteColor) { | 701 CPDF_DIBSource* CPDF_DIBSource::LoadMask(uint32_t& MatteColor) { |
| 702 MatteColor = 0xFFFFFFFF; | 702 MatteColor = 0xFFFFFFFF; |
| 703 CPDF_Stream* pSoftMask = m_pDict->GetStreamBy("SMask"); | 703 CPDF_Stream* pSoftMask = m_pDict->GetStreamFor("SMask"); |
| 704 if (pSoftMask) { | 704 if (pSoftMask) { |
| 705 CPDF_Array* pMatte = pSoftMask->GetDict()->GetArrayBy("Matte"); | 705 CPDF_Array* pMatte = pSoftMask->GetDict()->GetArrayFor("Matte"); |
| 706 if (pMatte && m_pColorSpace && | 706 if (pMatte && m_pColorSpace && |
| 707 m_pColorSpace->CountComponents() <= m_nComponents) { | 707 m_pColorSpace->CountComponents() <= m_nComponents) { |
| 708 std::vector<FX_FLOAT> colors(m_nComponents); | 708 std::vector<FX_FLOAT> colors(m_nComponents); |
| 709 for (uint32_t i = 0; i < m_nComponents; i++) { | 709 for (uint32_t i = 0; i < m_nComponents; i++) { |
| 710 colors[i] = pMatte->GetFloatAt(i); | 710 colors[i] = pMatte->GetFloatAt(i); |
| 711 } | 711 } |
| 712 FX_FLOAT R, G, B; | 712 FX_FLOAT R, G, B; |
| 713 m_pColorSpace->GetRGB(colors.data(), R, G, B); | 713 m_pColorSpace->GetRGB(colors.data(), R, G, B); |
| 714 MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), | 714 MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), |
| 715 FXSYS_round(B * 255)); | 715 FXSYS_round(B * 255)); |
| 716 } | 716 } |
| 717 return LoadMaskDIB(pSoftMask); | 717 return LoadMaskDIB(pSoftMask); |
| 718 } | 718 } |
| 719 | 719 |
| 720 if (CPDF_Stream* pStream = ToStream(m_pDict->GetDirectObjectBy("Mask"))) | 720 if (CPDF_Stream* pStream = ToStream(m_pDict->GetDirectObjectFor("Mask"))) |
| 721 return LoadMaskDIB(pStream); | 721 return LoadMaskDIB(pStream); |
| 722 | 722 |
| 723 return nullptr; | 723 return nullptr; |
| 724 } | 724 } |
| 725 | 725 |
| 726 int CPDF_DIBSource::StratLoadMask() { | 726 int CPDF_DIBSource::StratLoadMask() { |
| 727 m_MatteColor = 0XFFFFFFFF; | 727 m_MatteColor = 0XFFFFFFFF; |
| 728 m_pMaskStream = m_pDict->GetStreamBy("SMask"); | 728 m_pMaskStream = m_pDict->GetStreamFor("SMask"); |
| 729 if (m_pMaskStream) { | 729 if (m_pMaskStream) { |
| 730 CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayBy("Matte"); | 730 CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayFor("Matte"); |
| 731 if (pMatte && m_pColorSpace && | 731 if (pMatte && m_pColorSpace && |
| 732 m_pColorSpace->CountComponents() <= m_nComponents) { | 732 m_pColorSpace->CountComponents() <= m_nComponents) { |
| 733 FX_FLOAT R, G, B; | 733 FX_FLOAT R, G, B; |
| 734 std::vector<FX_FLOAT> colors(m_nComponents); | 734 std::vector<FX_FLOAT> colors(m_nComponents); |
| 735 for (uint32_t i = 0; i < m_nComponents; i++) { | 735 for (uint32_t i = 0; i < m_nComponents; i++) { |
| 736 colors[i] = pMatte->GetFloatAt(i); | 736 colors[i] = pMatte->GetFloatAt(i); |
| 737 } | 737 } |
| 738 m_pColorSpace->GetRGB(colors.data(), R, G, B); | 738 m_pColorSpace->GetRGB(colors.data(), R, G, B); |
| 739 m_MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), | 739 m_MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255), |
| 740 FXSYS_round(B * 255)); | 740 FXSYS_round(B * 255)); |
| 741 } | 741 } |
| 742 return StartLoadMaskDIB(); | 742 return StartLoadMaskDIB(); |
| 743 } | 743 } |
| 744 | 744 |
| 745 m_pMaskStream = ToStream(m_pDict->GetDirectObjectBy("Mask")); | 745 m_pMaskStream = ToStream(m_pDict->GetDirectObjectFor("Mask")); |
| 746 return m_pMaskStream ? StartLoadMaskDIB() : 1; | 746 return m_pMaskStream ? StartLoadMaskDIB() : 1; |
| 747 } | 747 } |
| 748 | 748 |
| 749 int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) { | 749 int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) { |
| 750 if (!m_pMask) { | 750 if (!m_pMask) { |
| 751 return 1; | 751 return 1; |
| 752 } | 752 } |
| 753 int ret = m_pMask->ContinueLoadDIBSource(pPause); | 753 int ret = m_pMask->ContinueLoadDIBSource(pPause); |
| 754 if (ret == 2) { | 754 if (ret == 2) { |
| 755 return ret; | 755 return ret; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 m_pColorSpace->GetRGB(color_value, R, G, B); | 862 m_pColorSpace->GetRGB(color_value, R, G, B); |
| 863 } | 863 } |
| 864 SetPaletteArgb(i, ArgbEncode(255, FXSYS_round(R * 255), | 864 SetPaletteArgb(i, ArgbEncode(255, FXSYS_round(R * 255), |
| 865 FXSYS_round(G * 255), FXSYS_round(B * 255))); | 865 FXSYS_round(G * 255), FXSYS_round(B * 255))); |
| 866 } | 866 } |
| 867 } | 867 } |
| 868 } | 868 } |
| 869 | 869 |
| 870 void CPDF_DIBSource::ValidateDictParam() { | 870 void CPDF_DIBSource::ValidateDictParam() { |
| 871 m_bpc = m_bpc_orig; | 871 m_bpc = m_bpc_orig; |
| 872 CPDF_Object* pFilter = m_pDict->GetDirectObjectBy("Filter"); | 872 CPDF_Object* pFilter = m_pDict->GetDirectObjectFor("Filter"); |
| 873 if (pFilter) { | 873 if (pFilter) { |
| 874 if (pFilter->IsName()) { | 874 if (pFilter->IsName()) { |
| 875 CFX_ByteString filter = pFilter->GetString(); | 875 CFX_ByteString filter = pFilter->GetString(); |
| 876 if (filter == "CCITTFaxDecode" || filter == "JBIG2Decode") { | 876 if (filter == "CCITTFaxDecode" || filter == "JBIG2Decode") { |
| 877 m_bpc = 1; | 877 m_bpc = 1; |
| 878 m_nComponents = 1; | 878 m_nComponents = 1; |
| 879 } else if (filter == "RunLengthDecode") { | 879 } else if (filter == "RunLengthDecode") { |
| 880 if (m_bpc != 1) { | 880 if (m_bpc != 1) { |
| 881 m_bpc = 8; | 881 m_bpc = 8; |
| 882 } | 882 } |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 IFX_Pause* pPause) { | 1550 IFX_Pause* pPause) { |
| 1551 return LoadHandle->Continue(pPause); | 1551 return LoadHandle->Continue(pPause); |
| 1552 } | 1552 } |
| 1553 | 1553 |
| 1554 CPDF_ImageLoader::~CPDF_ImageLoader() { | 1554 CPDF_ImageLoader::~CPDF_ImageLoader() { |
| 1555 if (!m_bCached) { | 1555 if (!m_bCached) { |
| 1556 delete m_pBitmap; | 1556 delete m_pBitmap; |
| 1557 delete m_pMask; | 1557 delete m_pMask; |
| 1558 } | 1558 } |
| 1559 } | 1559 } |
| OLD | NEW |