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

Side by Side Diff: core/fpdfapi/page/cpdf_image.cpp

Issue 2529543003: Add inline JPEGs. (Closed)
Patch Set: Fix rebase Created 4 years 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 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 data.resize(size); 133 data.resize(size);
134 pFile->ReadBlock(data.data(), 0, size); 134 pFile->ReadBlock(data.data(), 0, size);
135 pDict = InitJPEG(data.data(), size); 135 pDict = InitJPEG(data.data(), size);
136 } 136 }
137 if (!pDict) 137 if (!pDict)
138 return; 138 return;
139 139
140 m_pStream->InitStreamFromFile(pFile, std::move(pDict)); 140 m_pStream->InitStreamFromFile(pFile, std::move(pDict));
141 } 141 }
142 142
143 void CPDF_Image::SetJpegImageInline(
144 const CFX_RetainPtr<IFX_SeekableReadStream>& pFile) {
145 uint32_t size = (uint32_t)pFile->GetSize();
weili 2016/12/13 21:55:01 Avoid C-cast here pls
rbpotter 2016/12/14 01:03:28 Done.
146 if (!size)
147 return;
148
149 std::vector<uint8_t> data(size);
150 if (!pFile->ReadBlock(data.data(), 0, size))
151 return;
152
153 std::unique_ptr<CPDF_Dictionary> pDict = InitJPEG(data.data(), size);
154 if (!pDict)
155 return;
156
157 m_pStream->InitStream(&(data[0]), size, std::move(pDict));
weili 2016/12/13 21:55:00 Seems this line is the only diff with SetJpegImage
rbpotter 2016/12/14 01:03:28 There's actually another diff (the size), but I wa
Wei Li 2016/12/14 01:33:00 Sorry, didn't realize the size diff. Looks like ke
rbpotter 2016/12/14 18:03:36 Done.
158 }
159
143 void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap) { 160 void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap) {
144 int32_t BitmapWidth = pBitmap->GetWidth(); 161 int32_t BitmapWidth = pBitmap->GetWidth();
145 int32_t BitmapHeight = pBitmap->GetHeight(); 162 int32_t BitmapHeight = pBitmap->GetHeight();
146 if (BitmapWidth < 1 || BitmapHeight < 1) 163 if (BitmapWidth < 1 || BitmapHeight < 1)
147 return; 164 return;
148 165
149 auto pDict = 166 auto pDict =
150 pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool()); 167 pdfium::MakeUnique<CPDF_Dictionary>(m_pDocument->GetByteStringPool());
151 pDict->SetNewFor<CPDF_Name>("Type", "XObject"); 168 pDict->SetNewFor<CPDF_Name>("Type", "XObject");
152 pDict->SetNewFor<CPDF_Name>("Subtype", "Image"); 169 pDict->SetNewFor<CPDF_Name>("Subtype", "Image");
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 379 }
363 if (!ret) { 380 if (!ret) {
364 delete m_pDIBSource; 381 delete m_pDIBSource;
365 m_pDIBSource = nullptr; 382 m_pDIBSource = nullptr;
366 return false; 383 return false;
367 } 384 }
368 m_pMask = pSource->DetachMask(); 385 m_pMask = pSource->DetachMask();
369 m_MatteColor = pSource->GetMatteColor(); 386 m_MatteColor = pSource->GetMatteColor();
370 return false; 387 return false;
371 } 388 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/cpdf_image.h ('k') | fpdfsdk/fpdfeditimg.cpp » ('j') | fpdfsdk/fpdfeditimg.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698