Home | History | Annotate | Download | only in dib
      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_FXGE_DIB_DIB_INT_H_
      8 #define CORE_SRC_FXGE_DIB_DIB_INT_H_
      9 
     10 class CPDF_FixedMatrix
     11 {
     12 public:
     13     CPDF_FixedMatrix(const CFX_AffineMatrix& src, int bits)
     14     {
     15         base = 1 << bits;
     16         a = FXSYS_round(src.a * base);
     17         b = FXSYS_round(src.b * base);
     18         c = FXSYS_round(src.c * base);
     19         d = FXSYS_round(src.d * base);
     20         e = FXSYS_round(src.e * base);
     21         f = FXSYS_round(src.f * base);
     22     }
     23     inline void	Transform(int x, int y, int& x1, int& y1)
     24     {
     25         x1 = (a * x + c * y + e + base / 2) / base;
     26         y1 = (b * x + d * y + f + base / 2) / base;
     27     }
     28     int		a, b, c, d, e, f;
     29     int		base;
     30 };
     31 #define FPDF_HUGE_IMAGE_SIZE	60000000
     32 struct PixelWeight {
     33     int		m_SrcStart;
     34     int		m_SrcEnd;
     35     int		m_Weights[1];
     36 };
     37 class CWeightTable
     38 {
     39 public:
     40     CWeightTable()
     41     {
     42         m_pWeightTables = NULL;
     43     }
     44     ~CWeightTable()
     45     {
     46         if(m_pWeightTables) {
     47             FX_Free(m_pWeightTables);
     48         }
     49         m_pWeightTables = NULL;
     50     }
     51     void			Calc(int dest_len, int dest_min, int dest_max, int src_len, int src_min, int src_max, int flags);
     52     PixelWeight*	GetPixelWeight(int pixel)
     53     {
     54         return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize);
     55     }
     56     int				m_DestMin, m_ItemSize;
     57     FX_LPBYTE		m_pWeightTables;
     58 };
     59 class CStretchEngine
     60 {
     61 public:
     62     CStretchEngine(IFX_ScanlineComposer* pDestBitmap, FXDIB_Format dest_format,
     63                    int dest_width, int dest_height, const FX_RECT& clip_rect,
     64                    const CFX_DIBSource* pSrcBitmap, int flags);
     65     ~CStretchEngine();
     66     FX_BOOL		Continue(IFX_Pause* pPause);
     67 public:
     68     FXDIB_Format m_DestFormat;
     69     int		m_DestBpp, m_SrcBpp, m_bHasAlpha;
     70     IFX_ScanlineComposer*	m_pDestBitmap;
     71     int		m_DestWidth, m_DestHeight;
     72     FX_RECT	m_DestClip;
     73     FX_LPBYTE	m_pDestScanline;
     74     FX_LPBYTE   m_pDestMaskScanline;
     75     FX_RECT	m_SrcClip;
     76     const CFX_DIBSource*	m_pSource;
     77     FX_DWORD*	m_pSrcPalette;
     78     int		m_SrcWidth, m_SrcHeight;
     79     int		m_SrcPitch, m_InterPitch;
     80     int m_ExtraMaskPitch;
     81     unsigned char*	m_pInterBuf;
     82     unsigned char*	m_pExtraAlphaBuf;
     83     int		m_TransMethod;
     84     int 	m_Flags;
     85     CWeightTable	m_WeightTable;
     86     int		m_CurRow;
     87     FX_BOOL	StartStretchHorz();
     88     FX_BOOL	ContinueStretchHorz(IFX_Pause* pPause);
     89     void	StretchVert();
     90     int		m_State;
     91 };
     92 
     93 #endif  // CORE_SRC_FXGE_DIB_DIB_INT_H_
     94