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/page/cpdf_image.h" | 7 #include "core/fpdfapi/page/cpdf_image.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 pParms->SetIntegerFor("ColorTransform", 0); | 116 pParms->SetIntegerFor("ColorTransform", 0); |
117 } | 117 } |
118 m_bIsMask = FALSE; | 118 m_bIsMask = FALSE; |
119 m_Width = width; | 119 m_Width = width; |
120 m_Height = height; | 120 m_Height = height; |
121 if (!m_pStream) | 121 if (!m_pStream) |
122 m_pStream = new CPDF_Stream; | 122 m_pStream = new CPDF_Stream; |
123 return pDict; | 123 return pDict; |
124 } | 124 } |
125 | 125 |
126 void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) { | 126 void CPDF_Image::SetJpegImage(IFX_SeekableReadStream* pFile) { |
127 uint32_t size = (uint32_t)pFile->GetSize(); | 127 uint32_t size = (uint32_t)pFile->GetSize(); |
128 if (!size) | 128 if (!size) |
129 return; | 129 return; |
130 | 130 |
131 uint32_t dwEstimateSize = std::min(size, 8192U); | 131 uint32_t dwEstimateSize = std::min(size, 8192U); |
132 std::vector<uint8_t> data(dwEstimateSize); | 132 std::vector<uint8_t> data(dwEstimateSize); |
133 pFile->ReadBlock(data.data(), 0, dwEstimateSize); | 133 pFile->ReadBlock(data.data(), 0, dwEstimateSize); |
134 CPDF_Dictionary* pDict = InitJPEG(data.data(), dwEstimateSize); | 134 CPDF_Dictionary* pDict = InitJPEG(data.data(), dwEstimateSize); |
135 if (!pDict && size > dwEstimateSize) { | 135 if (!pDict && size > dwEstimateSize) { |
136 data.resize(size); | 136 data.resize(size); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 403 } |
404 if (!ret) { | 404 if (!ret) { |
405 delete m_pDIBSource; | 405 delete m_pDIBSource; |
406 m_pDIBSource = nullptr; | 406 m_pDIBSource = nullptr; |
407 return FALSE; | 407 return FALSE; |
408 } | 408 } |
409 m_pMask = pSource->DetachMask(); | 409 m_pMask = pSource->DetachMask(); |
410 m_MatteColor = pSource->GetMatteColor(); | 410 m_MatteColor = pSource->GetMatteColor(); |
411 return FALSE; | 411 return FALSE; |
412 } | 412 } |
OLD | NEW |