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_CODEC_CCODEC_PNGMODULE_H_ 8 #define CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_ 9 10 #include <memory> 11 12 #include "core/fxcrt/fx_system.h" 13 14 class CFX_DIBAttribute; 15 16 class CCodec_PngModule { 17 public: 18 class Context { 19 public: 20 virtual ~Context() {} 21 }; 22 23 class Delegate { 24 public: 25 virtual bool PngReadHeader(int width, 26 int height, 27 int bpc, 28 int pass, 29 int* color_type, 30 double* gamma) = 0; 31 32 // Returns true on success. |pSrcBuf| will be set if this succeeds. 33 // |pSrcBuf| does not take ownership of the buffer. 34 virtual bool PngAskScanlineBuf(int line, uint8_t** pSrcBuf) = 0; 35 36 virtual void PngFillScanlineBufCompleted(int pass, int line) = 0; 37 }; 38 39 std::unique_ptr<Context> Start(Delegate* pDelegate); 40 bool Input(Context* pContext, 41 const uint8_t* src_buf, 42 uint32_t src_size, 43 CFX_DIBAttribute* pAttribute); 44 }; 45 46 #endif // CORE_FXCODEC_CODEC_CCODEC_PNGMODULE_H_ 47