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

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

Issue 1824033002: Split core/include/fpdfapi/fpdf_resource.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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 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/fpdf_page/include/cpdf_image.h"
8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
10 #include "core/fpdfapi/include/cpdf_modulemgr.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
12 #include "core/include/fxge/fx_dib.h"
13 #include "core/fpdfapi/fpdf_page/pageint.h"
14 #include "core/include/fxcodec/fx_codec.h"
15 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
16 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
7 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 17 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
8 #include "core/fpdfapi/fpdf_page/pageint.h"
9 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
12 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
13 #include "core/fpdfapi/fpdf_parser/include/cpdf_string.h"
14 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" 18 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h"
15 #include "core/fpdfapi/fpdf_render/render_int.h" 19 #include "core/fpdfapi/fpdf_render/render_int.h"
16 #include "core/fpdfapi/include/cpdf_modulemgr.h" 20
17 #include "core/include/fxcodec/fx_codec.h" 21 CPDF_Image::CPDF_Image(CPDF_Document* pDoc)
22 : m_pDIBSource(nullptr),
23 m_pMask(nullptr),
24 m_MatteColor(0),
25 m_pStream(nullptr),
26 m_bInline(FALSE),
27 m_pInlineDict(nullptr),
28 m_pDocument(pDoc),
29 m_pOC(nullptr) {}
30
31 CPDF_Image::~CPDF_Image() {
32 if (m_bInline) {
33 if (m_pStream)
34 m_pStream->Release();
35 if (m_pInlineDict)
36 m_pInlineDict->Release();
37 }
38 }
39
40 void CPDF_Image::Release() {
41 if (m_bInline || (m_pStream && m_pStream->GetObjNum() == 0))
42 delete this;
43 }
44
45 CPDF_Image* CPDF_Image::Clone() {
46 if (m_pStream->GetObjNum())
47 return m_pDocument->GetPageData()->GetImage(m_pStream);
48
49 CPDF_Image* pImage = new CPDF_Image(m_pDocument);
50 pImage->LoadImageF(ToStream(m_pStream->Clone()), m_bInline);
51 if (m_bInline)
52 pImage->SetInlineDict(ToDictionary(m_pInlineDict->Clone(TRUE)));
53
54 return pImage;
55 }
56
57 FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline) {
58 m_pStream = pStream;
59 if (m_bInline && m_pInlineDict) {
60 m_pInlineDict->Release();
61 m_pInlineDict = NULL;
62 }
63 m_bInline = bInline;
64 CPDF_Dictionary* pDict = pStream->GetDict();
65 if (m_bInline) {
66 m_pInlineDict = ToDictionary(pDict->Clone());
67 }
68 m_pOC = pDict->GetDictBy("OC");
69 m_bIsMask =
70 !pDict->KeyExist("ColorSpace") || pDict->GetIntegerBy("ImageMask");
71 m_bInterpolate = pDict->GetIntegerBy("Interpolate");
72 m_Height = pDict->GetIntegerBy("Height");
73 m_Width = pDict->GetIntegerBy("Width");
74 return TRUE;
75 }
18 76
19 CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) { 77 CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) {
20 int32_t width; 78 int32_t width;
21 int32_t height; 79 int32_t height;
22 int32_t num_comps; 80 int32_t num_comps;
23 int32_t bits; 81 int32_t bits;
24 FX_BOOL color_trans; 82 FX_BOOL color_trans;
25 if (!CPDF_ModuleMgr::Get()->GetJpegModule()->LoadInfo( 83 if (!CPDF_ModuleMgr::Get()->GetJpegModule()->LoadInfo(
26 pData, size, width, height, num_comps, bits, color_trans)) { 84 pData, size, width, height, num_comps, bits, color_trans)) {
27 return NULL; 85 return NULL;
(...skipping 26 matching lines...) Expand all
54 pParms->SetAtInteger("ColorTransform", 0); 112 pParms->SetAtInteger("ColorTransform", 0);
55 } 113 }
56 m_bIsMask = FALSE; 114 m_bIsMask = FALSE;
57 m_Width = width; 115 m_Width = width;
58 m_Height = height; 116 m_Height = height;
59 if (!m_pStream) { 117 if (!m_pStream) {
60 m_pStream = new CPDF_Stream(NULL, 0, NULL); 118 m_pStream = new CPDF_Stream(NULL, 0, NULL);
61 } 119 }
62 return pDict; 120 return pDict;
63 } 121 }
122
64 void CPDF_Image::SetJpegImage(uint8_t* pData, FX_DWORD size) { 123 void CPDF_Image::SetJpegImage(uint8_t* pData, FX_DWORD size) {
65 CPDF_Dictionary* pDict = InitJPEG(pData, size); 124 CPDF_Dictionary* pDict = InitJPEG(pData, size);
66 if (!pDict) { 125 if (!pDict) {
67 return; 126 return;
68 } 127 }
69 m_pStream->InitStream(pData, size, pDict); 128 m_pStream->InitStream(pData, size, pDict);
70 } 129 }
130
71 void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) { 131 void CPDF_Image::SetJpegImage(IFX_FileRead* pFile) {
72 FX_DWORD size = (FX_DWORD)pFile->GetSize(); 132 FX_DWORD size = (FX_DWORD)pFile->GetSize();
73 if (!size) { 133 if (!size) {
74 return; 134 return;
75 } 135 }
76 FX_DWORD dwEstimateSize = size; 136 FX_DWORD dwEstimateSize = size;
77 if (dwEstimateSize > 8192) { 137 if (dwEstimateSize > 8192) {
78 dwEstimateSize = 8192; 138 dwEstimateSize = 8192;
79 } 139 }
80 uint8_t* pData = FX_Alloc(uint8_t, dwEstimateSize); 140 uint8_t* pData = FX_Alloc(uint8_t, dwEstimateSize);
81 pFile->ReadBlock(pData, 0, dwEstimateSize); 141 pFile->ReadBlock(pData, 0, dwEstimateSize);
82 CPDF_Dictionary* pDict = InitJPEG(pData, dwEstimateSize); 142 CPDF_Dictionary* pDict = InitJPEG(pData, dwEstimateSize);
83 FX_Free(pData); 143 FX_Free(pData);
84 if (!pDict && size > dwEstimateSize) { 144 if (!pDict && size > dwEstimateSize) {
85 pData = FX_Alloc(uint8_t, size); 145 pData = FX_Alloc(uint8_t, size);
86 pFile->ReadBlock(pData, 0, size); 146 pFile->ReadBlock(pData, 0, size);
87 pDict = InitJPEG(pData, size); 147 pDict = InitJPEG(pData, size);
88 FX_Free(pData); 148 FX_Free(pData);
89 } 149 }
90 if (!pDict) { 150 if (!pDict) {
91 return; 151 return;
92 } 152 }
93 m_pStream->InitStreamFromFile(pFile, pDict); 153 m_pStream->InitStreamFromFile(pFile, pDict);
94 } 154 }
95 void _DCTEncodeBitmap(CPDF_Dictionary* pBitmapDict, 155
96 const CFX_DIBitmap* pBitmap,
97 int quality,
98 uint8_t*& buf,
99 FX_STRSIZE& size) {}
100 void _JBIG2EncodeBitmap(CPDF_Dictionary* pBitmapDict,
101 const CFX_DIBitmap* pBitmap,
102 CPDF_Document* pDoc,
103 uint8_t*& buf,
104 FX_STRSIZE& size,
105 FX_BOOL bLossLess) {}
106 void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, 156 void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap,
107 int32_t iCompress, 157 int32_t iCompress,
108 IFX_FileWrite* pFileWrite, 158 IFX_FileWrite* pFileWrite,
109 IFX_FileRead* pFileRead, 159 IFX_FileRead* pFileRead,
110 const CFX_DIBitmap* pMask, 160 const CFX_DIBitmap* pMask) {
111 const CPDF_ImageSetParam* pParam) {
112 int32_t BitmapWidth = pBitmap->GetWidth(); 161 int32_t BitmapWidth = pBitmap->GetWidth();
113 int32_t BitmapHeight = pBitmap->GetHeight(); 162 int32_t BitmapHeight = pBitmap->GetHeight();
114 if (BitmapWidth < 1 || BitmapHeight < 1) { 163 if (BitmapWidth < 1 || BitmapHeight < 1) {
115 return; 164 return;
116 } 165 }
117 uint8_t* src_buf = pBitmap->GetBuffer(); 166 uint8_t* src_buf = pBitmap->GetBuffer();
118 int32_t src_pitch = pBitmap->GetPitch(); 167 int32_t src_pitch = pBitmap->GetPitch();
119 int32_t bpp = pBitmap->GetBPP(); 168 int32_t bpp = pBitmap->GetBPP();
120 FX_BOOL bUseMatte = 169
121 pParam && pParam->pMatteColor && (pBitmap->GetFormat() == FXDIB_Argb);
122 CPDF_Dictionary* pDict = new CPDF_Dictionary; 170 CPDF_Dictionary* pDict = new CPDF_Dictionary;
123 pDict->SetAtName("Type", "XObject"); 171 pDict->SetAtName("Type", "XObject");
124 pDict->SetAtName("Subtype", "Image"); 172 pDict->SetAtName("Subtype", "Image");
125 pDict->SetAtInteger("Width", BitmapWidth); 173 pDict->SetAtInteger("Width", BitmapWidth);
126 pDict->SetAtInteger("Height", BitmapHeight); 174 pDict->SetAtInteger("Height", BitmapHeight);
127 uint8_t* dest_buf = NULL; 175 uint8_t* dest_buf = NULL;
128 FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1; 176 FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1;
129 if (bpp == 1) { 177 if (bpp == 1) {
130 int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0; 178 int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0;
131 int32_t set_a = 0, set_r = 0, set_g = 0, set_b = 0; 179 int32_t set_a = 0, set_r = 0, set_g = 0, set_b = 0;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 FX_STRSIZE mask_size = 0; 275 FX_STRSIZE mask_size = 0;
228 CPDF_Dictionary* pMaskDict = new CPDF_Dictionary; 276 CPDF_Dictionary* pMaskDict = new CPDF_Dictionary;
229 pMaskDict->SetAtName("Type", "XObject"); 277 pMaskDict->SetAtName("Type", "XObject");
230 pMaskDict->SetAtName("Subtype", "Image"); 278 pMaskDict->SetAtName("Subtype", "Image");
231 pMaskDict->SetAtInteger("Width", maskWidth); 279 pMaskDict->SetAtInteger("Width", maskWidth);
232 pMaskDict->SetAtInteger("Height", maskHeight); 280 pMaskDict->SetAtInteger("Height", maskHeight);
233 pMaskDict->SetAtName("ColorSpace", "DeviceGray"); 281 pMaskDict->SetAtName("ColorSpace", "DeviceGray");
234 pMaskDict->SetAtInteger("BitsPerComponent", 8); 282 pMaskDict->SetAtInteger("BitsPerComponent", 8);
235 if (pMaskBitmap->GetBPP() == 8 && 283 if (pMaskBitmap->GetBPP() == 8 &&
236 (iCompress & PDF_IMAGE_MASK_LOSSY_COMPRESS) != 0) { 284 (iCompress & PDF_IMAGE_MASK_LOSSY_COMPRESS) != 0) {
237 _DCTEncodeBitmap(pMaskDict, pMaskBitmap, pParam ? pParam->nQuality : 75,
238 mask_buf, mask_size);
239 } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) { 285 } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) {
240 _JBIG2EncodeBitmap(pMaskDict, pMaskBitmap, m_pDocument, mask_buf,
241 mask_size, TRUE);
242 } else { 286 } else {
243 mask_buf = FX_Alloc2D(uint8_t, maskHeight, maskWidth); 287 mask_buf = FX_Alloc2D(uint8_t, maskHeight, maskWidth);
244 mask_size = maskHeight * maskWidth; // Safe since checked alloc returned. 288 mask_size = maskHeight * maskWidth; // Safe since checked alloc returned.
245 for (int32_t a = 0; a < maskHeight; a++) { 289 for (int32_t a = 0; a < maskHeight; a++) {
246 FXSYS_memcpy(mask_buf + a * maskWidth, pMaskBitmap->GetScanline(a), 290 FXSYS_memcpy(mask_buf + a * maskWidth, pMaskBitmap->GetScanline(a),
247 maskWidth); 291 maskWidth);
248 } 292 }
249 } 293 }
250 pMaskDict->SetAtInteger("Length", mask_size); 294 pMaskDict->SetAtInteger("Length", mask_size);
251 if (bUseMatte) { 295
252 int a, r, g, b;
253 ArgbDecode(*(pParam->pMatteColor), a, r, g, b);
254 CPDF_Array* pMatte = new CPDF_Array;
255 pMatte->AddInteger(r);
256 pMatte->AddInteger(g);
257 pMatte->AddInteger(b);
258 pMaskDict->SetAt("Matte", pMatte);
259 }
260 CPDF_Stream* pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict); 296 CPDF_Stream* pMaskStream = new CPDF_Stream(mask_buf, mask_size, pMaskDict);
261 m_pDocument->AddIndirectObject(pMaskStream); 297 m_pDocument->AddIndirectObject(pMaskStream);
262 pDict->SetAtReference("SMask", m_pDocument, pMaskStream); 298 pDict->SetAtReference("SMask", m_pDocument, pMaskStream);
263 if (bDeleteMask) { 299 if (bDeleteMask) {
264 delete pMaskBitmap; 300 delete pMaskBitmap;
265 } 301 }
266 } 302 }
267 FX_BOOL bStream = pFileWrite && pFileRead; 303 FX_BOOL bStream = pFileWrite && pFileRead;
268 if (opType == 0) { 304 if (opType == 0) {
269 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { 305 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) {
270 if (pBitmap->GetBPP() == 1) {
271 _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_size,
272 TRUE);
273 }
274 } else { 306 } else {
275 if (pBitmap->GetBPP() == 1) { 307 if (pBitmap->GetBPP() == 1) {
276 _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_size,
277 FALSE);
278 } else if (pBitmap->GetBPP() >= 8 && pBitmap->GetPalette()) { 308 } else if (pBitmap->GetBPP() >= 8 && pBitmap->GetPalette()) {
279 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap(); 309 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap();
280 pNewBitmap->Copy(pBitmap); 310 pNewBitmap->Copy(pBitmap);
281 pNewBitmap->ConvertFormat(FXDIB_Rgb); 311 pNewBitmap->ConvertFormat(FXDIB_Rgb);
282 SetImage(pNewBitmap, iCompress, pFileWrite, pFileRead); 312 SetImage(pNewBitmap, iCompress, pFileWrite, pFileRead);
283 if (pDict) { 313 if (pDict) {
284 pDict->Release(); 314 pDict->Release();
285 pDict = NULL; 315 pDict = NULL;
286 } 316 }
287 FX_Free(dest_buf); 317 FX_Free(dest_buf);
288 dest_buf = NULL; 318 dest_buf = NULL;
289 dest_size = 0; 319 dest_size = 0;
290 delete pNewBitmap; 320 delete pNewBitmap;
291 return; 321 return;
292 } else {
293 if (bUseMatte) {
294 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap();
295 pNewBitmap->Create(BitmapWidth, BitmapHeight, FXDIB_Argb);
296 uint8_t* dst_buf = pNewBitmap->GetBuffer();
297 int32_t src_offset = 0;
298 for (int32_t row = 0; row < BitmapHeight; row++) {
299 src_offset = row * src_pitch;
300 for (int32_t column = 0; column < BitmapWidth; column++) {
301 FX_FLOAT alpha = src_buf[src_offset + 3] / 255.0f;
302 dst_buf[src_offset] = (uint8_t)(src_buf[src_offset] * alpha);
303 dst_buf[src_offset + 1] =
304 (uint8_t)(src_buf[src_offset + 1] * alpha);
305 dst_buf[src_offset + 2] =
306 (uint8_t)(src_buf[src_offset + 2] * alpha);
307 dst_buf[src_offset + 3] = (uint8_t)(src_buf[src_offset + 3]);
308 src_offset += 4;
309 }
310 }
311 _DCTEncodeBitmap(pDict, pNewBitmap, pParam ? pParam->nQuality : 75,
312 dest_buf, dest_size);
313 delete pNewBitmap;
314 } else {
315 _DCTEncodeBitmap(pDict, pBitmap, pParam ? pParam->nQuality : 75,
316 dest_buf, dest_size);
317 }
318 } 322 }
319 } 323 }
320 if (bStream) { 324 if (bStream) {
321 pFileWrite->WriteBlock(dest_buf, dest_size); 325 pFileWrite->WriteBlock(dest_buf, dest_size);
322 FX_Free(dest_buf); 326 FX_Free(dest_buf);
323 dest_buf = NULL; 327 dest_buf = NULL;
324 } 328 }
325 } else if (opType == 1) { 329 } else if (opType == 1) {
326 if (!bStream) { 330 if (!bStream) {
327 dest_buf = FX_Alloc2D(uint8_t, dest_pitch, BitmapHeight); 331 dest_buf = FX_Alloc2D(uint8_t, dest_pitch, BitmapHeight);
(...skipping 17 matching lines...) Expand all
345 dest_pitch * BitmapHeight; // Safe since checked alloc returned. 349 dest_pitch * BitmapHeight; // Safe since checked alloc returned.
346 } else { 350 } else {
347 dest_buf = FX_Alloc(uint8_t, dest_pitch); 351 dest_buf = FX_Alloc(uint8_t, dest_pitch);
348 } 352 }
349 uint8_t* pDest = dest_buf; 353 uint8_t* pDest = dest_buf;
350 int32_t src_offset = 0; 354 int32_t src_offset = 0;
351 int32_t dest_offset = 0; 355 int32_t dest_offset = 0;
352 for (int32_t row = 0; row < BitmapHeight; row++) { 356 for (int32_t row = 0; row < BitmapHeight; row++) {
353 src_offset = row * src_pitch; 357 src_offset = row * src_pitch;
354 for (int32_t column = 0; column < BitmapWidth; column++) { 358 for (int32_t column = 0; column < BitmapWidth; column++) {
355 FX_FLOAT alpha = bUseMatte ? src_buf[src_offset + 3] / 255.0f : 1; 359 FX_FLOAT alpha = 1;
356 pDest[dest_offset] = (uint8_t)(src_buf[src_offset + 2] * alpha); 360 pDest[dest_offset] = (uint8_t)(src_buf[src_offset + 2] * alpha);
357 pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha); 361 pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha);
358 pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha); 362 pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha);
359 dest_offset += 3; 363 dest_offset += 3;
360 src_offset += bpp == 24 ? 3 : 4; 364 src_offset += bpp == 24 ? 3 : 4;
361 } 365 }
362 if (bStream) { 366 if (bStream) {
363 pFileWrite->WriteBlock(pDest, dest_pitch); 367 pFileWrite->WriteBlock(pDest, dest_pitch);
364 pDest = dest_buf; 368 pDest = dest_buf;
365 } else { 369 } else {
(...skipping 13 matching lines...) Expand all
379 m_pStream->InitStream(dest_buf, dest_size, pDict); 383 m_pStream->InitStream(dest_buf, dest_size, pDict);
380 } else { 384 } else {
381 pFileWrite->Flush(); 385 pFileWrite->Flush();
382 m_pStream->InitStreamFromFile(pFileRead, pDict); 386 m_pStream->InitStreamFromFile(pFileRead, pDict);
383 } 387 }
384 m_bIsMask = pBitmap->IsAlphaMask(); 388 m_bIsMask = pBitmap->IsAlphaMask();
385 m_Width = BitmapWidth; 389 m_Width = BitmapWidth;
386 m_Height = BitmapHeight; 390 m_Height = BitmapHeight;
387 FX_Free(dest_buf); 391 FX_Free(dest_buf);
388 } 392 }
393
389 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) { 394 void CPDF_Image::ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pBitmap) {
390 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap); 395 pPage->GetRenderCache()->ResetBitmap(m_pStream, pBitmap);
391 } 396 }
397
398 CFX_DIBSource* CPDF_Image::LoadDIBSource(CFX_DIBSource** ppMask,
399 FX_DWORD* pMatteColor,
400 FX_BOOL bStdCS,
401 FX_DWORD GroupFamily,
402 FX_BOOL bLoadMask) const {
403 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource);
404 if (source->Load(m_pDocument, m_pStream,
405 reinterpret_cast<CPDF_DIBSource**>(ppMask), pMatteColor,
406 nullptr, nullptr, bStdCS, GroupFamily, bLoadMask)) {
407 return source.release();
408 }
409 return nullptr;
410 }
411
412 CFX_DIBSource* CPDF_Image::DetachBitmap() {
413 CFX_DIBSource* pBitmap = m_pDIBSource;
414 m_pDIBSource = nullptr;
415 return pBitmap;
416 }
417
418 CFX_DIBSource* CPDF_Image::DetachMask() {
419 CFX_DIBSource* pBitmap = m_pMask;
420 m_pMask = nullptr;
421 return pBitmap;
422 }
423
424 FX_BOOL CPDF_Image::StartLoadDIBSource(CPDF_Dictionary* pFormResource,
425 CPDF_Dictionary* pPageResource,
426 FX_BOOL bStdCS,
427 FX_DWORD GroupFamily,
428 FX_BOOL bLoadMask) {
429 std::unique_ptr<CPDF_DIBSource> source(new CPDF_DIBSource);
430 int ret =
431 source->StartLoadDIBSource(m_pDocument, m_pStream, TRUE, pFormResource,
432 pPageResource, bStdCS, GroupFamily, bLoadMask);
433 if (ret == 2) {
434 m_pDIBSource = source.release();
435 return TRUE;
436 }
437 if (!ret) {
438 m_pDIBSource = nullptr;
439 return FALSE;
440 }
441 m_pMask = source->DetachMask();
442 m_MatteColor = source->GetMatteColor();
443 m_pDIBSource = source.release();
444 return FALSE;
445 }
446
447 FX_BOOL CPDF_Image::Continue(IFX_Pause* pPause) {
448 CPDF_DIBSource* pSource = static_cast<CPDF_DIBSource*>(m_pDIBSource);
449 int ret = pSource->ContinueLoadDIBSource(pPause);
450 if (ret == 2) {
451 return TRUE;
452 }
453 if (!ret) {
454 delete m_pDIBSource;
455 m_pDIBSource = nullptr;
456 return FALSE;
457 }
458 m_pMask = pSource->DetachMask();
459 m_MatteColor = pSource->GetMatteColor();
460 return FALSE;
461 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_countedobject.h ('k') | core/fpdfapi/fpdf_page/cpdf_imageobject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698