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 #ifndef CORE_FXCODEC_ICC_ICCMODULE_H_ 8 #define CORE_FXCODEC_ICC_ICCMODULE_H_ 9 10 #include <memory> 11 12 #include "core/fxcodec/fx_codec_def.h" 13 #include "core/fxcrt/fx_string.h" 14 #include "core/fxcrt/fx_system.h" 15 #include "third_party/base/span.h" 16 17 #if defined(USE_SYSTEM_LCMS2) 18 #include <lcms2.h> 19 #else 20 #include "third_party/lcms/include/lcms2.h" 21 #endif 22 23 namespace fxcodec { 24 25 class CLcmsCmm { 26 public: 27 CLcmsCmm(cmsHTRANSFORM transform, 28 int srcComponents, 29 bool bIsLab, 30 bool bNormal); 31 ~CLcmsCmm(); 32 transform()33 cmsHTRANSFORM transform() const { return m_hTransform; } components()34 int components() const { return m_nSrcComponents; } IsLab()35 bool IsLab() const { return m_bLab; } IsNormal()36 bool IsNormal() const { return m_bNormal; } 37 38 private: 39 const cmsHTRANSFORM m_hTransform; 40 const int m_nSrcComponents; 41 const bool m_bLab; 42 const bool m_bNormal; 43 }; 44 45 class IccModule { 46 public: 47 static std::unique_ptr<CLcmsCmm> CreateTransformSRGB( 48 pdfium::span<const uint8_t> span); 49 static void Translate(CLcmsCmm* pTransform, 50 uint32_t nSrcComponents, 51 const float* pSrcValues, 52 float* pDestValues); 53 static void TranslateScanline(CLcmsCmm* pTransform, 54 uint8_t* pDest, 55 const uint8_t* pSrc, 56 int pixels); 57 58 IccModule() = delete; 59 IccModule(const IccModule&) = delete; 60 IccModule& operator=(const IccModule&) = delete; 61 }; 62 63 } // namespace fxcodec 64 65 using CLcmsCmm = fxcodec::CLcmsCmm; 66 using IccModule = fxcodec::IccModule; 67 68 #endif // CORE_FXCODEC_ICC_ICCMODULE_H_ 69