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_SRC_FXCODEC_JBIG2_JBIG2_IMAGE_H_
8 #define CORE_SRC_FXCODEC_JBIG2_JBIG2_IMAGE_H_
9 
10 #include "JBig2_Define.h"
11 
12 enum JBig2ComposeOp {
13   JBIG2_COMPOSE_OR = 0,
14   JBIG2_COMPOSE_AND = 1,
15   JBIG2_COMPOSE_XOR = 2,
16   JBIG2_COMPOSE_XNOR = 3,
17   JBIG2_COMPOSE_REPLACE = 4
18 };
19 
20 struct FX_RECT;
21 class CJBig2_Image {
22  public:
23   CJBig2_Image(int32_t w, int32_t h);
24 
25   CJBig2_Image(int32_t w, int32_t h, int32_t stride, uint8_t* pBuf);
26 
27   CJBig2_Image(const CJBig2_Image& im);
28 
29   ~CJBig2_Image();
30 
31   FX_BOOL getPixel(int32_t x, int32_t y);
32 
33   int32_t setPixel(int32_t x, int32_t y, FX_BOOL v);
34 
35   void copyLine(int32_t hTo, int32_t hFrom);
36 
37   void fill(FX_BOOL v);
38 
39   FX_BOOL composeTo(CJBig2_Image* pDst,
40                     int32_t x,
41                     int32_t y,
42                     JBig2ComposeOp op);
43   FX_BOOL composeTo(CJBig2_Image* pDst,
44                     int32_t x,
45                     int32_t y,
46                     JBig2ComposeOp op,
47                     const FX_RECT* pSrcRect);
48 
49   FX_BOOL composeTo_opt2(CJBig2_Image* pDst,
50                          int32_t x,
51                          int32_t y,
52                          JBig2ComposeOp op);
53   FX_BOOL composeTo_opt2(CJBig2_Image* pDst,
54                          int32_t x,
55                          int32_t y,
56                          JBig2ComposeOp op,
57                          const FX_RECT* pSrcRect);
58 
59   FX_BOOL composeFrom(int32_t x,
60                       int32_t y,
61                       CJBig2_Image* pSrc,
62                       JBig2ComposeOp op);
63   FX_BOOL composeFrom(int32_t x,
64                       int32_t y,
65                       CJBig2_Image* pSrc,
66                       JBig2ComposeOp op,
67                       const FX_RECT* pSrcRect);
68 
69   CJBig2_Image* subImage(int32_t x, int32_t y, int32_t w, int32_t h);
70 
71   void expand(int32_t h, FX_BOOL v);
72 
73  public:
74   int32_t m_nWidth;
75 
76   int32_t m_nHeight;
77 
78   int32_t m_nStride;
79 
80   uint8_t* m_pData;
81 
82   FX_BOOL m_bNeedFree;
83 };
84 
85 #endif  // CORE_SRC_FXCODEC_JBIG2_JBIG2_IMAGE_H_
86