• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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/fpdfapi/render/cpdf_transferfunc.h"
8 
9 #include "core/fpdfapi/parser/cpdf_document.h"
10 #include "core/fpdfapi/render/cpdf_dibtransferfunc.h"
11 #include "core/fxge/dib/cfx_dibsource.h"
12 
CPDF_TransferFunc(CPDF_Document * pDoc)13 CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {}
14 
~CPDF_TransferFunc()15 CPDF_TransferFunc::~CPDF_TransferFunc() {}
16 
TranslateColor(FX_COLORREF rgb) const17 FX_COLORREF CPDF_TransferFunc::TranslateColor(FX_COLORREF rgb) const {
18   return FXSYS_RGB(m_Samples[FXSYS_GetRValue(rgb)],
19                    m_Samples[256 + FXSYS_GetGValue(rgb)],
20                    m_Samples[512 + FXSYS_GetBValue(rgb)]);
21 }
22 
TranslateImage(const RetainPtr<CFX_DIBSource> & pSrc)23 RetainPtr<CFX_DIBSource> CPDF_TransferFunc::TranslateImage(
24     const RetainPtr<CFX_DIBSource>& pSrc) {
25   RetainPtr<CPDF_TransferFunc> pHolder(this);
26   auto pDest = pdfium::MakeRetain<CPDF_DIBTransferFunc>(pHolder);
27   pDest->LoadSrc(pSrc);
28   return pDest;
29 }
30