OLD | NEW |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 m_pOC = pDict->GetDictFor("OC"); | 48 m_pOC = pDict->GetDictFor("OC"); |
49 m_bIsMask = | 49 m_bIsMask = |
50 !pDict->KeyExist("ColorSpace") || pDict->GetIntegerFor("ImageMask"); | 50 !pDict->KeyExist("ColorSpace") || pDict->GetIntegerFor("ImageMask"); |
51 m_bInterpolate = !!pDict->GetIntegerFor("Interpolate"); | 51 m_bInterpolate = !!pDict->GetIntegerFor("Interpolate"); |
52 m_Height = pDict->GetIntegerFor("Height"); | 52 m_Height = pDict->GetIntegerFor("Height"); |
53 m_Width = pDict->GetIntegerFor("Width"); | 53 m_Width = pDict->GetIntegerFor("Width"); |
54 } | 54 } |
55 | 55 |
56 CPDF_Image::~CPDF_Image() { | 56 CPDF_Image::~CPDF_Image() { |
57 if (m_bInline) { | 57 if (m_bInline) { |
58 if (m_pStream) | 58 delete m_pStream; |
59 m_pStream->Release(); | 59 delete m_pInlineDict; |
60 if (m_pInlineDict) | |
61 m_pInlineDict->Release(); | |
62 } | 60 } |
63 } | 61 } |
64 | 62 |
65 CPDF_Image* CPDF_Image::Clone() { | 63 CPDF_Image* CPDF_Image::Clone() { |
66 if (m_pStream->GetObjNum()) | 64 if (m_pStream->GetObjNum()) |
67 return m_pDocument->GetPageData()->GetImage(m_pStream); | 65 return m_pDocument->GetPageData()->GetImage(m_pStream); |
68 | 66 |
69 CPDF_Image* pImage = | 67 CPDF_Image* pImage = |
70 new CPDF_Image(m_pDocument, ToStream(m_pStream->Clone()), m_bInline); | 68 new CPDF_Image(m_pDocument, ToStream(m_pStream->Clone()), m_bInline); |
71 if (m_bInline) | 69 if (m_bInline) |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 279 } |
282 if (opType == 0) { | 280 if (opType == 0) { |
283 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { | 281 if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { |
284 } else { | 282 } else { |
285 if (pBitmap->GetBPP() == 1) { | 283 if (pBitmap->GetBPP() == 1) { |
286 } else if (pBitmap->GetBPP() >= 8 && pBitmap->GetPalette()) { | 284 } else if (pBitmap->GetBPP() >= 8 && pBitmap->GetPalette()) { |
287 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap(); | 285 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap(); |
288 pNewBitmap->Copy(pBitmap); | 286 pNewBitmap->Copy(pBitmap); |
289 pNewBitmap->ConvertFormat(FXDIB_Rgb); | 287 pNewBitmap->ConvertFormat(FXDIB_Rgb); |
290 SetImage(pNewBitmap, iCompress); | 288 SetImage(pNewBitmap, iCompress); |
291 if (pDict) { | 289 delete pDict; |
292 pDict->Release(); | 290 pDict = nullptr; |
293 pDict = nullptr; | |
294 } | |
295 FX_Free(dest_buf); | 291 FX_Free(dest_buf); |
296 dest_buf = nullptr; | 292 dest_buf = nullptr; |
297 dest_size = 0; | 293 dest_size = 0; |
298 delete pNewBitmap; | 294 delete pNewBitmap; |
299 return; | 295 return; |
300 } | 296 } |
301 } | 297 } |
302 } else if (opType == 1) { | 298 } else if (opType == 1) { |
303 dest_buf = FX_Alloc2D(uint8_t, dest_pitch, BitmapHeight); | 299 dest_buf = FX_Alloc2D(uint8_t, dest_pitch, BitmapHeight); |
304 dest_size = dest_pitch * BitmapHeight; // Safe as checked alloc returned. | 300 dest_size = dest_pitch * BitmapHeight; // Safe as checked alloc returned. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 } | 398 } |
403 if (!ret) { | 399 if (!ret) { |
404 delete m_pDIBSource; | 400 delete m_pDIBSource; |
405 m_pDIBSource = nullptr; | 401 m_pDIBSource = nullptr; |
406 return FALSE; | 402 return FALSE; |
407 } | 403 } |
408 m_pMask = pSource->DetachMask(); | 404 m_pMask = pSource->DetachMask(); |
409 m_MatteColor = pSource->GetMatteColor(); | 405 m_MatteColor = pSource->GetMatteColor(); |
410 return FALSE; | 406 return FALSE; |
411 } | 407 } |
OLD | NEW |