1 // Copyright 2017 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "core/fxge/dib/cfx_dibextractor.h" 8 9 #include "core/fxge/dib/cfx_dibbase.h" 10 #include "core/fxge/dib/cfx_dibitmap.h" 11 CFX_DIBExtractor(const RetainPtr<CFX_DIBBase> & pSrc)12CFX_DIBExtractor::CFX_DIBExtractor(const RetainPtr<CFX_DIBBase>& pSrc) { 13 if (!pSrc->GetBuffer()) { 14 m_pBitmap = pSrc->Clone(nullptr); 15 return; 16 } 17 RetainPtr<CFX_DIBBase> pOldSrc(pSrc); 18 m_pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); 19 if (!m_pBitmap->Create(pOldSrc->GetWidth(), pOldSrc->GetHeight(), 20 pOldSrc->GetFormat(), pOldSrc->GetBuffer(), 0)) { 21 m_pBitmap.Reset(); 22 return; 23 } 24 m_pBitmap->SetPalette(pOldSrc->GetPalette()); 25 m_pBitmap->SetAlphaMask(pOldSrc->m_pAlphaMask, nullptr); 26 } 27 ~CFX_DIBExtractor()28CFX_DIBExtractor::~CFX_DIBExtractor() {} 29