summaryrefslogtreecommitdiff
path: root/core/fxge/dib/cfx_dibextractor.cpp
blob: 8de69e2e3bc8540f5873ccdb38cdb25771eb3698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2017 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "core/fxge/dib/cfx_dibextractor.h"

#include "core/fxge/dib/cfx_dibsource.h"

CFX_DIBExtractor::CFX_DIBExtractor(const CFX_RetainPtr<CFX_DIBSource>& pSrc) {
  if (!pSrc->GetBuffer()) {
    m_pBitmap = pSrc->Clone();
    return;
  }
  CFX_RetainPtr<CFX_DIBSource> pOldSrc(pSrc);
  m_pBitmap = pdfium::MakeRetain<CFX_DIBitmap>();
  if (!m_pBitmap->Create(pOldSrc->GetWidth(), pOldSrc->GetHeight(),
                         pOldSrc->GetFormat(), pOldSrc->GetBuffer())) {
    m_pBitmap.Reset();
    return;
  }
  m_pBitmap->SetPalette(pOldSrc->GetPalette());
  m_pBitmap->SetAlphaMask(pOldSrc->m_pAlphaMask);
}

CFX_DIBExtractor::~CFX_DIBExtractor() {}