1 // Copyright 2022 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 #ifndef CORE_FPDFAPI_PAGE_CPDF_INDEXEDCS_H_ 6 #define CORE_FPDFAPI_PAGE_CPDF_INDEXEDCS_H_ 7 8 #include <stdint.h> 9 10 #include <set> 11 12 #include "core/fpdfapi/page/cpdf_basedcs.h" 13 #include "core/fxcrt/data_vector.h" 14 #include "core/fxcrt/fx_memory_wrappers.h" 15 #include "core/fxcrt/retain_ptr.h" 16 17 class CPDF_Document; 18 19 struct IndexedColorMinMax { 20 float min; 21 float max; 22 }; 23 FX_DATA_PARTITION_EXCEPTION(IndexedColorMinMax); 24 25 class CPDF_IndexedCS final : public CPDF_BasedCS { 26 public: 27 CONSTRUCT_VIA_MAKE_RETAIN; 28 ~CPDF_IndexedCS() override; 29 30 // CPDF_ColorSpace: 31 std::optional<FX_RGB_STRUCT<float>> GetRGB( 32 pdfium::span<const float> pBuf) const override; 33 const CPDF_IndexedCS* AsIndexedCS() const override; 34 uint32_t v_Load(CPDF_Document* pDoc, 35 const CPDF_Array* pArray, 36 std::set<const CPDF_Object*>* pVisited) override; 37 GetMaxIndex()38 int GetMaxIndex() const { return max_index_; } 39 40 private: 41 CPDF_IndexedCS(); 42 43 int max_index_ = 0; 44 DataVector<uint8_t> lookup_table_; 45 DataVector<IndexedColorMinMax> component_min_max_; 46 }; 47 48 #endif // CORE_FPDFAPI_PAGE_CPDF_INDEXEDCS_H_ 49