| 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_page/pageint.h" | 7 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 11 #include "core/include/fpdfapi/fpdf_pageobj.h" | |
| 12 | 11 |
| 13 CPDF_ImageObject::CPDF_ImageObject() : m_pImage(nullptr) {} | |
| 14 | |
| 15 CPDF_ImageObject::~CPDF_ImageObject() { | |
| 16 if (!m_pImage) { | |
| 17 return; | |
| 18 } | |
| 19 if (m_pImage->IsInline() || | |
| 20 (m_pImage->GetStream() && m_pImage->GetStream()->GetObjNum() == 0)) { | |
| 21 delete m_pImage; | |
| 22 } else { | |
| 23 m_pImage->GetDocument()->GetPageData()->ReleaseImage(m_pImage->GetStream()); | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 CPDF_ImageObject* CPDF_ImageObject::Clone() const { | |
| 28 CPDF_ImageObject* obj = new CPDF_ImageObject; | |
| 29 obj->CopyData(this); | |
| 30 | |
| 31 obj->m_pImage = m_pImage->Clone(); | |
| 32 obj->m_Matrix = m_Matrix; | |
| 33 return obj; | |
| 34 } | |
| 35 | |
| 36 void CPDF_ImageObject::Transform(const CFX_Matrix& matrix) { | |
| 37 m_Matrix.Concat(matrix); | |
| 38 CalcBoundingBox(); | |
| 39 } | |
| 40 void CPDF_ImageObject::CalcBoundingBox() { | |
| 41 m_Left = m_Bottom = 0; | |
| 42 m_Right = m_Top = 1.0f; | |
| 43 m_Matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom); | |
| 44 } | |
| 45 void CPDF_Image::Release() { | 12 void CPDF_Image::Release() { |
| 46 if (m_bInline || (m_pStream && m_pStream->GetObjNum() == 0)) { | 13 if (m_bInline || (m_pStream && m_pStream->GetObjNum() == 0)) { |
| 47 delete this; | 14 delete this; |
| 48 } | 15 } |
| 49 } | 16 } |
| 50 CPDF_Image* CPDF_Image::Clone() { | 17 CPDF_Image* CPDF_Image::Clone() { |
| 51 if (m_pStream->GetObjNum()) | 18 if (m_pStream->GetObjNum()) |
| 52 return m_pDocument->GetPageData()->GetImage(m_pStream); | 19 return m_pDocument->GetPageData()->GetImage(m_pStream); |
| 53 | 20 |
| 54 CPDF_Image* pImage = new CPDF_Image(m_pDocument); | 21 CPDF_Image* pImage = new CPDF_Image(m_pDocument); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 m_pInlineDict = ToDictionary(pDict->Clone()); | 57 m_pInlineDict = ToDictionary(pDict->Clone()); |
| 91 } | 58 } |
| 92 m_pOC = pDict->GetDictBy("OC"); | 59 m_pOC = pDict->GetDictBy("OC"); |
| 93 m_bIsMask = | 60 m_bIsMask = |
| 94 !pDict->KeyExist("ColorSpace") || pDict->GetIntegerBy("ImageMask"); | 61 !pDict->KeyExist("ColorSpace") || pDict->GetIntegerBy("ImageMask"); |
| 95 m_bInterpolate = pDict->GetIntegerBy("Interpolate"); | 62 m_bInterpolate = pDict->GetIntegerBy("Interpolate"); |
| 96 m_Height = pDict->GetIntegerBy("Height"); | 63 m_Height = pDict->GetIntegerBy("Height"); |
| 97 m_Width = pDict->GetIntegerBy("Width"); | 64 m_Width = pDict->GetIntegerBy("Width"); |
| 98 return TRUE; | 65 return TRUE; |
| 99 } | 66 } |
| OLD | NEW |