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

Side by Side Diff: core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp

Issue 2494683007: Fix sevg above CPDF_PageContentGenerator::ProcessImage() (Closed)
Patch Set: Use IsInline() Created 4 years, 1 month 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
« no previous file with comments | « no previous file | fpdfsdk/fpdfeditimg_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/edit/cpdf_pagecontentgenerator.h" 7 #include "core/fpdfapi/edit/cpdf_pagecontentgenerator.h"
8 8
9 #include "core/fpdfapi/edit/cpdf_creator.h" 9 #include "core/fpdfapi/edit/cpdf_creator.h"
10 #include "core/fpdfapi/page/cpdf_docpagedata.h" 10 #include "core/fpdfapi/page/cpdf_docpagedata.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return name; 87 return name;
88 } 88 }
89 89
90 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf, 90 void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf,
91 CPDF_ImageObject* pImageObj) { 91 CPDF_ImageObject* pImageObj) {
92 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) || 92 if ((pImageObj->m_Matrix.a == 0 && pImageObj->m_Matrix.b == 0) ||
93 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) { 93 (pImageObj->m_Matrix.c == 0 && pImageObj->m_Matrix.d == 0)) {
94 return; 94 return;
95 } 95 }
96 buf << "q " << pImageObj->m_Matrix << " cm "; 96 buf << "q " << pImageObj->m_Matrix << " cm ";
97
97 CPDF_Image* pImage = pImageObj->GetImage(); 98 CPDF_Image* pImage = pImageObj->GetImage();
98 if (!pImage->IsInline()) { 99 if (pImage->IsInline())
99 CPDF_Stream* pStream = pImage->GetStream(); 100 return;
100 uint32_t dwSavedObjNum = pStream->GetObjNum(); 101
101 CFX_ByteString name = RealizeResource(pStream, "XObject"); 102 CPDF_Stream* pStream = pImage->GetStream();
102 if (dwSavedObjNum == 0) { 103 if (!pStream)
103 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream)); 104 return;
104 } 105
105 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; 106 bool bWasInline = pStream->IsInline();
106 } 107 CFX_ByteString name = RealizeResource(pStream, "XObject");
108 if (bWasInline)
109 pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream));
110
111 buf << "/" << PDF_NameEncode(name) << " Do Q\n";
107 } 112 }
108 113
109 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf, 114 void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf,
110 const uint8_t* data, 115 const uint8_t* data,
111 uint32_t size, 116 uint32_t size,
112 CFX_Matrix& matrix) { 117 CFX_Matrix& matrix) {
113 if (!data || !size) 118 if (!data || !size)
114 return; 119 return;
115 120
116 CPDF_Dictionary* pFormDict = 121 CPDF_Dictionary* pFormDict =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } else if (CPDF_Stream* pStream = pContent->AsStream()) { 173 } else if (CPDF_Stream* pStream = pContent->AsStream()) {
169 CPDF_StreamAcc contentStream; 174 CPDF_StreamAcc contentStream;
170 contentStream.LoadAllData(pStream); 175 contentStream.LoadAllData(pStream);
171 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); 176 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix);
172 } 177 }
173 CPDF_Stream* pStream = new CPDF_Stream; 178 CPDF_Stream* pStream = new CPDF_Stream;
174 pStream->SetData(buf.GetBuffer(), buf.GetLength()); 179 pStream->SetData(buf.GetBuffer(), buf.GetLength());
175 m_pPage->m_pFormDict->SetReferenceFor( 180 m_pPage->m_pFormDict->SetReferenceFor(
176 "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream)); 181 "Contents", m_pDocument, m_pDocument->AddIndirectObject(pStream));
177 } 182 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/fpdfeditimg_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698