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 "../../../../third_party/base/nonstd_unique_ptr.h" | 7 #include "../../../../third_party/base/nonstd_unique_ptr.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../../include/fpdfapi/fpdf_pageobj.h" |
10 #include "../../../include/fpdfapi/fpdf_render.h" | 10 #include "../../../include/fpdfapi/fpdf_render.h" |
11 #include "../../../include/fxcodec/fx_codec.h" | 11 #include "../../../include/fxcodec/fx_codec.h" |
12 #include "../../../include/fxcrt/fx_safe_types.h" | 12 #include "../../../include/fxcrt/fx_safe_types.h" |
13 #include "../../../include/fxge/fx_ge.h" | 13 #include "../../../include/fxge/fx_ge.h" |
14 #include "../fpdf_page/pageint.h" | 14 #include "../fpdf_page/pageint.h" |
15 #include "render_int.h" | 15 #include "render_int.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits) | 19 unsigned int _GetBits8(const uint8_t* pData, int bitpos, int nbits) |
20 { | 20 { |
21 unsigned int byte = pData[bitpos / 8]; | 21 unsigned int byte = pData[bitpos / 8]; |
22 if (nbits == 8) { | 22 if (nbits == 8) { |
23 return byte; | 23 return byte; |
24 } else if (nbits == 4) { | 24 } |
| 25 if (nbits == 4) { |
25 return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); | 26 return (bitpos % 8) ? (byte & 0x0f) : (byte >> 4); |
26 } else if (nbits == 2) { | 27 } |
| 28 if (nbits == 2) { |
27 return (byte >> (6 - bitpos % 8)) & 0x03; | 29 return (byte >> (6 - bitpos % 8)) & 0x03; |
28 } else if (nbits == 1) { | 30 } |
| 31 if (nbits == 1) { |
29 return (byte >> (7 - bitpos % 8)) & 0x01; | 32 return (byte >> (7 - bitpos % 8)) & 0x01; |
30 } else if (nbits == 16) { | 33 } |
| 34 if (nbits == 16) { |
31 return byte * 256 + pData[bitpos / 8 + 1]; | 35 return byte * 256 + pData[bitpos / 8 + 1]; |
32 } | 36 } |
33 return 0; | 37 return 0; |
34 } | 38 } |
35 | 39 |
36 FX_SAFE_DWORD CalculatePitch8(FX_DWORD bpc, | 40 FX_SAFE_DWORD CalculatePitch8(FX_DWORD bpc, |
37 FX_DWORD components, | 41 FX_DWORD components, |
38 int width, | 42 int width, |
39 int height) | 43 int height) |
40 { | 44 { |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 ret1 = ContinueLoadMaskDIB(pPause); | 459 ret1 = ContinueLoadMaskDIB(pPause); |
456 m_Status = 2; | 460 m_Status = 2; |
457 } | 461 } |
458 if (ret1 == 2) { | 462 if (ret1 == 2) { |
459 return ret1; | 463 return ret1; |
460 } | 464 } |
461 if (m_pColorSpace && m_bStdCS) { | 465 if (m_pColorSpace && m_bStdCS) { |
462 m_pColorSpace->EnableStdConversion(FALSE); | 466 m_pColorSpace->EnableStdConversion(FALSE); |
463 } | 467 } |
464 return ret1; | 468 return ret1; |
465 } else if (m_Status == 2) { | 469 } |
| 470 if (m_Status == 2) { |
466 return ContinueLoadMaskDIB(pPause); | 471 return ContinueLoadMaskDIB(pPause); |
467 } | 472 } |
468 return 0; | 473 return 0; |
469 } | 474 } |
470 FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dict
ionary* pPageResources) | 475 FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dict
ionary* pPageResources) |
471 { | 476 { |
472 m_bpc_orig = m_pDict->GetInteger(FX_BSTRC("BitsPerComponent")); | 477 m_bpc_orig = m_pDict->GetInteger(FX_BSTRC("BitsPerComponent")); |
473 if (m_pDict->GetInteger("ImageMask")) { | 478 if (m_pDict->GetInteger("ImageMask")) { |
474 m_bImageMask = TRUE; | 479 m_bImageMask = TRUE; |
475 } | 480 } |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 G = NORMALCOLOR_MAX(G, max_data); | 1006 G = NORMALCOLOR_MAX(G, max_data); |
1002 B = NORMALCOLOR_MAX(B, max_data); | 1007 B = NORMALCOLOR_MAX(B, max_data); |
1003 dest_scan[dest_byte_pos] = B * 255 / max_data; | 1008 dest_scan[dest_byte_pos] = B * 255 / max_data; |
1004 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; | 1009 dest_scan[dest_byte_pos + 1] = G * 255 / max_data; |
1005 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; | 1010 dest_scan[dest_byte_pos + 2] = R * 255 / max_data; |
1006 dest_byte_pos += 3; | 1011 dest_byte_pos += 3; |
1007 } | 1012 } |
1008 break; | 1013 break; |
1009 } | 1014 } |
1010 return; | 1015 return; |
1011 } else if (m_bpc == 8) { | 1016 } |
| 1017 if (m_bpc == 8) { |
1012 if (m_nComponents == m_pColorSpace->CountComponents()) | 1018 if (m_nComponents == m_pColorSpace->CountComponents()) |
1013 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width,
m_Width, m_Height, | 1019 m_pColorSpace->TranslateImageLine(dest_scan, src_scan, m_Width,
m_Width, m_Height, |
1014 m_bLoadMask && m_GroupFamily =
= PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); | 1020 m_bLoadMask && m_GroupFamily =
= PDFCS_DEVICECMYK && m_Family == PDFCS_DEVICECMYK); |
1015 return; | 1021 return; |
1016 } | 1022 } |
1017 } | 1023 } |
1018 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); | 1024 CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); |
1019 FX_FLOAT* color_values = color_values1; | 1025 FX_FLOAT* color_values = color_values1; |
1020 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; | 1026 FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; |
1021 if (m_bpc == 8) { | 1027 if (m_bpc == 8) { |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 { | 1556 { |
1551 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); | 1557 return ((CPDF_ProgressiveImageLoaderHandle*)LoadHandle)->Continue(pPause); |
1552 } | 1558 } |
1553 CPDF_ImageLoader::~CPDF_ImageLoader() | 1559 CPDF_ImageLoader::~CPDF_ImageLoader() |
1554 { | 1560 { |
1555 if (!m_bCached) { | 1561 if (!m_bCached) { |
1556 delete m_pBitmap; | 1562 delete m_pBitmap; |
1557 delete m_pMask; | 1563 delete m_pMask; |
1558 } | 1564 } |
1559 } | 1565 } |
OLD | NEW |