• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_BMP_BMPMODULE_H_
8 #define CORE_FXCODEC_BMP_BMPMODULE_H_
9 
10 #include <memory>
11 #include <vector>
12 
13 #include "core/fxcodec/codec_module_iface.h"
14 #include "third_party/base/span.h"
15 
16 namespace fxcodec {
17 
18 class CFX_DIBAttribute;
19 
20 class BmpModule final : public ModuleIface {
21  public:
22   class Delegate {
23    public:
24     virtual bool BmpInputImagePositionBuf(uint32_t rcd_pos) = 0;
25     virtual void BmpReadScanline(uint32_t row_num,
26                                  pdfium::span<const uint8_t> row_buf) = 0;
27   };
28 
29   enum class Status : uint8_t { kFail, kSuccess, kContinue };
30 
31   BmpModule();
32   ~BmpModule() override;
33 
34   // ModuleIface:
35   FX_FILESIZE GetAvailInput(Context* pContext) const override;
36   bool Input(Context* pContext,
37              RetainPtr<CFX_CodecMemory> codec_memory,
38              CFX_DIBAttribute* pAttribute) override;
39 
40   std::unique_ptr<Context> Start(Delegate* pDelegate);
41   Status ReadHeader(Context* pContext,
42                     int32_t* width,
43                     int32_t* height,
44                     bool* tb_flag,
45                     int32_t* components,
46                     int32_t* pal_num,
47                     const std::vector<uint32_t>** palette,
48                     CFX_DIBAttribute* pAttribute);
49   Status LoadImage(Context* pContext);
50 };
51 
52 }  // namespace fxcodec
53 
54 using BmpModule = fxcodec::BmpModule;
55 
56 #endif  // CORE_FXCODEC_BMP_BMPMODULE_H_
57