| OLD | NEW |
| (Empty) |
| 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_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ | |
| 8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "core/fxcrt/include/fx_string.h" | |
| 13 #include "core/fxcrt/include/fx_system.h" | |
| 14 | |
| 15 #define PDFCS_DEVICEGRAY 1 | |
| 16 #define PDFCS_DEVICERGB 2 | |
| 17 #define PDFCS_DEVICECMYK 3 | |
| 18 #define PDFCS_CALGRAY 4 | |
| 19 #define PDFCS_CALRGB 5 | |
| 20 #define PDFCS_LAB 6 | |
| 21 #define PDFCS_ICCBASED 7 | |
| 22 #define PDFCS_SEPARATION 8 | |
| 23 #define PDFCS_DEVICEN 9 | |
| 24 #define PDFCS_INDEXED 10 | |
| 25 #define PDFCS_PATTERN 11 | |
| 26 | |
| 27 class CPDF_Array; | |
| 28 class CPDF_Document; | |
| 29 class CPDF_Object; | |
| 30 | |
| 31 class CPDF_ColorSpace { | |
| 32 public: | |
| 33 static CPDF_ColorSpace* GetStockCS(int Family); | |
| 34 static CPDF_ColorSpace* ColorspaceFromName(const CFX_ByteString& name); | |
| 35 static std::unique_ptr<CPDF_ColorSpace> Load(CPDF_Document* pDoc, | |
| 36 CPDF_Object* pCSObj); | |
| 37 | |
| 38 void Release(); | |
| 39 | |
| 40 int GetBufSize() const; | |
| 41 FX_FLOAT* CreateBuf(); | |
| 42 void GetDefaultColor(FX_FLOAT* buf) const; | |
| 43 uint32_t CountComponents() const; | |
| 44 int GetFamily() const { return m_Family; } | |
| 45 virtual void GetDefaultValue(int iComponent, | |
| 46 FX_FLOAT& value, | |
| 47 FX_FLOAT& min, | |
| 48 FX_FLOAT& max) const; | |
| 49 | |
| 50 FX_BOOL sRGB() const; | |
| 51 virtual FX_BOOL GetRGB(FX_FLOAT* pBuf, | |
| 52 FX_FLOAT& R, | |
| 53 FX_FLOAT& G, | |
| 54 FX_FLOAT& B) const = 0; | |
| 55 virtual FX_BOOL SetRGB(FX_FLOAT* pBuf, | |
| 56 FX_FLOAT R, | |
| 57 FX_FLOAT G, | |
| 58 FX_FLOAT B) const; | |
| 59 | |
| 60 FX_BOOL GetCMYK(FX_FLOAT* pBuf, | |
| 61 FX_FLOAT& c, | |
| 62 FX_FLOAT& m, | |
| 63 FX_FLOAT& y, | |
| 64 FX_FLOAT& k) const; | |
| 65 FX_BOOL SetCMYK(FX_FLOAT* pBuf, | |
| 66 FX_FLOAT c, | |
| 67 FX_FLOAT m, | |
| 68 FX_FLOAT y, | |
| 69 FX_FLOAT k) const; | |
| 70 | |
| 71 virtual void TranslateImageLine(uint8_t* dest_buf, | |
| 72 const uint8_t* src_buf, | |
| 73 int pixels, | |
| 74 int image_width, | |
| 75 int image_height, | |
| 76 FX_BOOL bTransMask = FALSE) const; | |
| 77 | |
| 78 CPDF_Array*& GetArray() { return m_pArray; } | |
| 79 virtual CPDF_ColorSpace* GetBaseCS() const; | |
| 80 | |
| 81 virtual void EnableStdConversion(FX_BOOL bEnabled); | |
| 82 | |
| 83 CPDF_Document* const m_pDocument; | |
| 84 | |
| 85 protected: | |
| 86 CPDF_ColorSpace(CPDF_Document* pDoc, int family, uint32_t nComponents); | |
| 87 virtual ~CPDF_ColorSpace(); | |
| 88 | |
| 89 virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray); | |
| 90 virtual FX_BOOL v_GetCMYK(FX_FLOAT* pBuf, | |
| 91 FX_FLOAT& c, | |
| 92 FX_FLOAT& m, | |
| 93 FX_FLOAT& y, | |
| 94 FX_FLOAT& k) const; | |
| 95 virtual FX_BOOL v_SetCMYK(FX_FLOAT* pBuf, | |
| 96 FX_FLOAT c, | |
| 97 FX_FLOAT m, | |
| 98 FX_FLOAT y, | |
| 99 FX_FLOAT k) const; | |
| 100 | |
| 101 int m_Family; | |
| 102 uint32_t m_nComponents; | |
| 103 CPDF_Array* m_pArray; | |
| 104 uint32_t m_dwStdConversion; | |
| 105 }; | |
| 106 | |
| 107 namespace std { | |
| 108 | |
| 109 // Make std::unique_ptr<CPDF_ColorSpace> call Release() rather than | |
| 110 // simply deleting the object. | |
| 111 template <> | |
| 112 struct default_delete<CPDF_ColorSpace> { | |
| 113 void operator()(CPDF_ColorSpace* pColorSpace) const { | |
| 114 if (pColorSpace) | |
| 115 pColorSpace->Release(); | |
| 116 } | |
| 117 }; | |
| 118 | |
| 119 } // namespace std | |
| 120 | |
| 121 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_ | |
| OLD | NEW |