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