OLD | NEW |
| (Empty) |
1 // Copyright 2014 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #include "core/fpdfapi/fpdf_page/pageint.h" | |
8 | |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | |
11 | |
12 void CPDF_Image::Release() { | |
13 if (m_bInline || (m_pStream && m_pStream->GetObjNum() == 0)) { | |
14 delete this; | |
15 } | |
16 } | |
17 CPDF_Image* CPDF_Image::Clone() { | |
18 if (m_pStream->GetObjNum()) | |
19 return m_pDocument->GetPageData()->GetImage(m_pStream); | |
20 | |
21 CPDF_Image* pImage = new CPDF_Image(m_pDocument); | |
22 pImage->LoadImageF(ToStream(m_pStream->Clone()), m_bInline); | |
23 if (m_bInline) | |
24 pImage->SetInlineDict(ToDictionary(m_pInlineDict->Clone(TRUE))); | |
25 | |
26 return pImage; | |
27 } | |
28 CPDF_Image::CPDF_Image(CPDF_Document* pDoc) { | |
29 m_pDocument = pDoc; | |
30 m_pStream = NULL; | |
31 m_pOC = NULL; | |
32 m_bInline = FALSE; | |
33 m_pInlineDict = NULL; | |
34 m_pDIBSource = NULL; | |
35 m_pMask = NULL; | |
36 m_MatteColor = 0; | |
37 } | |
38 CPDF_Image::~CPDF_Image() { | |
39 if (m_bInline) { | |
40 if (m_pStream) { | |
41 m_pStream->Release(); | |
42 } | |
43 if (m_pInlineDict) { | |
44 m_pInlineDict->Release(); | |
45 } | |
46 } | |
47 } | |
48 FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline) { | |
49 m_pStream = pStream; | |
50 if (m_bInline && m_pInlineDict) { | |
51 m_pInlineDict->Release(); | |
52 m_pInlineDict = NULL; | |
53 } | |
54 m_bInline = bInline; | |
55 CPDF_Dictionary* pDict = pStream->GetDict(); | |
56 if (m_bInline) { | |
57 m_pInlineDict = ToDictionary(pDict->Clone()); | |
58 } | |
59 m_pOC = pDict->GetDictBy("OC"); | |
60 m_bIsMask = | |
61 !pDict->KeyExist("ColorSpace") || pDict->GetIntegerBy("ImageMask"); | |
62 m_bInterpolate = pDict->GetIntegerBy("Interpolate"); | |
63 m_Height = pDict->GetIntegerBy("Height"); | |
64 m_Width = pDict->GetIntegerBy("Width"); | |
65 return TRUE; | |
66 } | |
OLD | NEW |