1 // Copyright 2014 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_FX_CODEC_H_ 8 #define CORE_FXCODEC_FX_CODEC_H_ 9 10 #include <map> 11 #include <memory> 12 #include <tuple> 13 #include <utility> 14 #include <vector> 15 16 #include "core/fxcodec/fx_codec_def.h" 17 #include "core/fxcrt/fx_coordinates.h" 18 #include "core/fxcrt/fx_string.h" 19 20 class CCodec_BasicModule; 21 class CCodec_FaxModule; 22 class CCodec_FlateModule; 23 class CCodec_IccModule; 24 class CCodec_Jbig2Module; 25 class CCodec_JpegModule; 26 class CCodec_JpxModule; 27 class CFX_DIBSource; 28 class CJPX_Decoder; 29 class CPDF_ColorSpace; 30 class CPDF_StreamAcc; 31 32 #ifdef PDF_ENABLE_XFA 33 class CCodec_BmpModule; 34 class CCodec_GifModule; 35 class CCodec_PngModule; 36 class CCodec_ProgressiveDecoder; 37 class CCodec_TiffModule; 38 39 class CFX_DIBAttribute { 40 public: 41 CFX_DIBAttribute(); 42 ~CFX_DIBAttribute(); 43 44 int32_t m_nXDPI; 45 int32_t m_nYDPI; 46 float m_fAspectRatio; 47 uint16_t m_wDPIUnit; 48 ByteString m_strAuthor; 49 int32_t m_nGifLeft; 50 int32_t m_nGifTop; 51 uint32_t* m_pGifLocalPalette; 52 uint32_t m_nGifLocalPalNum; 53 int32_t m_nBmpCompressType; 54 std::map<uint32_t, void*> m_Exif; 55 }; 56 #endif // PDF_ENABLE_XFA 57 58 class CCodec_ModuleMgr { 59 public: 60 CCodec_ModuleMgr(); 61 ~CCodec_ModuleMgr(); 62 63 CCodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } 64 CCodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } 65 CCodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } 66 CCodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } 67 CCodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } 68 CCodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } 69 CCodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } 70 71 #ifdef PDF_ENABLE_XFA 72 std::unique_ptr<CCodec_ProgressiveDecoder> CreateProgressiveDecoder(); 73 void SetBmpModule(std::unique_ptr<CCodec_BmpModule> module); 74 void SetGifModule(std::unique_ptr<CCodec_GifModule> module); 75 void SetPngModule(std::unique_ptr<CCodec_PngModule> module); 76 void SetTiffModule(std::unique_ptr<CCodec_TiffModule> module); 77 CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } 78 CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } 79 CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } 80 CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } 81 #endif // PDF_ENABLE_XFA 82 83 protected: 84 std::unique_ptr<CCodec_BasicModule> m_pBasicModule; 85 std::unique_ptr<CCodec_FaxModule> m_pFaxModule; 86 std::unique_ptr<CCodec_JpegModule> m_pJpegModule; 87 std::unique_ptr<CCodec_JpxModule> m_pJpxModule; 88 std::unique_ptr<CCodec_Jbig2Module> m_pJbig2Module; 89 std::unique_ptr<CCodec_IccModule> m_pIccModule; 90 91 #ifdef PDF_ENABLE_XFA 92 std::unique_ptr<CCodec_BmpModule> m_pBmpModule; 93 std::unique_ptr<CCodec_GifModule> m_pGifModule; 94 std::unique_ptr<CCodec_PngModule> m_pPngModule; 95 std::unique_ptr<CCodec_TiffModule> m_pTiffModule; 96 #endif // PDF_ENABLE_XFA 97 98 std::unique_ptr<CCodec_FlateModule> m_pFlateModule; 99 }; 100 101 void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels); 102 uint32_t ComponentsForFamily(int family); 103 std::tuple<float, float, float> AdobeCMYK_to_sRGB(float c, 104 float m, 105 float y, 106 float k); 107 std::tuple<uint8_t, uint8_t, uint8_t> AdobeCMYK_to_sRGB1(uint8_t c, 108 uint8_t m, 109 uint8_t y, 110 uint8_t k); 111 void FaxG4Decode(const uint8_t* src_buf, 112 uint32_t src_size, 113 int* pbitpos, 114 uint8_t* dest_buf, 115 int width, 116 int height, 117 int pitch); 118 119 #endif // CORE_FXCODEC_FX_CODEC_H_ 120