1 // Copyright 2017 The PDFium Authors 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().empty()) { 14 m_pBitmap = pSrc->Realize(); 15 return; 16 } 17 m_pBitmap = pdfium::MakeRetain<CFX_DIBitmap>(); 18 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), pSrc->GetFormat(), 19 pSrc->GetBuffer().data(), 20 /*pitch=*/0)) { 21 m_pBitmap.Reset(); 22 return; 23 } 24 25 m_pBitmap->SetPalette(pSrc->GetPaletteSpan()); 26 } 27 28 CFX_DIBExtractor::~CFX_DIBExtractor() = default; 29