Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "../../../include/fpdfapi/fpdf_page.h" 7 #include "../../../include/fpdfapi/fpdf_page.h"
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "pageint.h" 9 #include "pageint.h"
10 CPDF_ImageObject::CPDF_ImageObject() 10 CPDF_ImageObject::CPDF_ImageObject() {
11 { 11 m_pImage = NULL;
12 m_pImage = NULL; 12 m_Type = PDFPAGE_IMAGE;
13 m_Type = PDFPAGE_IMAGE;
14 } 13 }
15 CPDF_ImageObject::~CPDF_ImageObject() 14 CPDF_ImageObject::~CPDF_ImageObject() {
16 { 15 if (!m_pImage) {
17 if (!m_pImage) { 16 return;
18 return; 17 }
18 if (m_pImage->IsInline() ||
19 (m_pImage->GetStream() && m_pImage->GetStream()->GetObjNum() == 0)) {
20 delete m_pImage;
21 } else {
22 m_pImage->GetDocument()->GetPageData()->ReleaseImage(m_pImage->GetStream());
23 }
24 }
25 void CPDF_ImageObject::CopyData(const CPDF_PageObject* pSrc) {
26 const CPDF_ImageObject* pSrcObj = (const CPDF_ImageObject*)pSrc;
27 if (m_pImage) {
28 m_pImage->Release();
29 }
30 m_pImage = pSrcObj->m_pImage->Clone();
31 m_Matrix = pSrcObj->m_Matrix;
32 }
33 void CPDF_ImageObject::Transform(const CFX_AffineMatrix& matrix) {
34 m_Matrix.Concat(matrix);
35 CalcBoundingBox();
36 }
37 void CPDF_ImageObject::CalcBoundingBox() {
38 m_Left = m_Bottom = 0;
39 m_Right = m_Top = 1.0f;
40 m_Matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
41 }
42 void CPDF_Image::Release() {
43 if (m_bInline || (m_pStream && m_pStream->GetObjNum() == 0)) {
44 delete this;
45 }
46 }
47 CPDF_Image* CPDF_Image::Clone() {
48 if (m_pStream->GetObjNum()) {
49 return m_pDocument->GetPageData()->GetImage(m_pStream);
50 }
51 CPDF_Image* pImage = new CPDF_Image(m_pDocument);
52 pImage->LoadImageF((CPDF_Stream*)((CPDF_Object*)m_pStream)->Clone(),
53 m_bInline);
54 if (m_bInline) {
55 CPDF_Dictionary* pInlineDict = (CPDF_Dictionary*)m_pInlineDict->Clone(TRUE);
56 pImage->SetInlineDict(pInlineDict);
57 }
58 return pImage;
59 }
60 CPDF_Image::CPDF_Image(CPDF_Document* pDoc) {
61 m_pDocument = pDoc;
62 m_pStream = NULL;
63 m_pOC = NULL;
64 m_bInline = FALSE;
65 m_pInlineDict = NULL;
66 m_pDIBSource = NULL;
67 m_pMask = NULL;
68 m_MatteColor = 0;
69 }
70 CPDF_Image::~CPDF_Image() {
71 if (m_bInline) {
72 if (m_pStream) {
73 m_pStream->Release();
19 } 74 }
20 if (m_pImage->IsInline() || (m_pImage->GetStream() && m_pImage->GetStream()- >GetObjNum() == 0)) { 75 if (m_pInlineDict) {
21 delete m_pImage; 76 m_pInlineDict->Release();
22 } else {
23 m_pImage->GetDocument()->GetPageData()->ReleaseImage(m_pImage->GetStream ());
24 } 77 }
78 }
25 } 79 }
26 void CPDF_ImageObject::CopyData(const CPDF_PageObject* pSrc) 80 FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline) {
27 { 81 m_pStream = pStream;
28 const CPDF_ImageObject* pSrcObj = (const CPDF_ImageObject*)pSrc; 82 if (m_bInline && m_pInlineDict) {
29 if (m_pImage) { 83 m_pInlineDict->Release();
30 m_pImage->Release(); 84 m_pInlineDict = NULL;
31 } 85 }
32 m_pImage = pSrcObj->m_pImage->Clone(); 86 m_bInline = bInline;
33 m_Matrix = pSrcObj->m_Matrix; 87 CPDF_Dictionary* pDict = pStream->GetDict();
88 if (m_bInline) {
89 m_pInlineDict = (CPDF_Dictionary*)pDict->Clone();
90 }
91 m_pOC = pDict->GetDict(FX_BSTRC("OC"));
92 m_bIsMask = !pDict->KeyExist(FX_BSTRC("ColorSpace")) ||
93 pDict->GetInteger(FX_BSTRC("ImageMask"));
94 m_bInterpolate = pDict->GetInteger(FX_BSTRC("Interpolate"));
95 m_Height = pDict->GetInteger(FX_BSTRC("Height"));
96 m_Width = pDict->GetInteger(FX_BSTRC("Width"));
97 return TRUE;
34 } 98 }
35 void CPDF_ImageObject::Transform(const CFX_AffineMatrix& matrix)
36 {
37 m_Matrix.Concat(matrix);
38 CalcBoundingBox();
39 }
40 void CPDF_ImageObject::CalcBoundingBox()
41 {
42 m_Left = m_Bottom = 0;
43 m_Right = m_Top = 1.0f;
44 m_Matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
45 }
46 void CPDF_Image::Release()
47 {
48 if (m_bInline || (m_pStream && m_pStream->GetObjNum() == 0)) {
49 delete this;
50 }
51 }
52 CPDF_Image* CPDF_Image::Clone()
53 {
54 if (m_pStream->GetObjNum()) {
55 return m_pDocument->GetPageData()->GetImage(m_pStream);
56 }
57 CPDF_Image* pImage = new CPDF_Image(m_pDocument);
58 pImage->LoadImageF((CPDF_Stream*)((CPDF_Object*)m_pStream)->Clone(), m_bInli ne);
59 if (m_bInline) {
60 CPDF_Dictionary *pInlineDict = (CPDF_Dictionary*)m_pInlineDict->Clone(TR UE);
61 pImage->SetInlineDict(pInlineDict);
62 }
63 return pImage;
64 }
65 CPDF_Image::CPDF_Image(CPDF_Document* pDoc)
66 {
67 m_pDocument = pDoc;
68 m_pStream = NULL;
69 m_pOC = NULL;
70 m_bInline = FALSE;
71 m_pInlineDict = NULL;
72 m_pDIBSource = NULL;
73 m_pMask = NULL;
74 m_MatteColor = 0;
75 }
76 CPDF_Image::~CPDF_Image()
77 {
78 if (m_bInline) {
79 if (m_pStream) {
80 m_pStream->Release();
81 }
82 if (m_pInlineDict) {
83 m_pInlineDict->Release();
84 }
85 }
86 }
87 FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline)
88 {
89 m_pStream = pStream;
90 if (m_bInline && m_pInlineDict) {
91 m_pInlineDict->Release();
92 m_pInlineDict = NULL;
93 }
94 m_bInline = bInline;
95 CPDF_Dictionary* pDict = pStream->GetDict();
96 if (m_bInline) {
97 m_pInlineDict = (CPDF_Dictionary*)pDict->Clone();
98 }
99 m_pOC = pDict->GetDict(FX_BSTRC("OC"));
100 m_bIsMask = !pDict->KeyExist(FX_BSTRC("ColorSpace")) || pDict->GetInteger(FX _BSTRC("ImageMask"));
101 m_bInterpolate = pDict->GetInteger(FX_BSTRC("Interpolate"));
102 m_Height = pDict->GetInteger(FX_BSTRC("Height"));
103 m_Width = pDict->GetInteger(FX_BSTRC("Width"));
104 return TRUE;
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698