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_INCLUDE_FXGE_FX_DIB_H_
8 #define CORE_INCLUDE_FXGE_FX_DIB_H_
9
10 #include "../fxcrt/fx_ext.h"
11
12 enum FXDIB_Format {
13 FXDIB_Invalid = 0,
14 FXDIB_1bppMask = 0x101,
15 FXDIB_1bppRgb = 0x001,
16 FXDIB_1bppCmyk = 0x401,
17 FXDIB_8bppMask = 0x108,
18 FXDIB_8bppRgb = 0x008,
19 FXDIB_8bppRgba = 0x208,
20 FXDIB_8bppCmyk = 0x408,
21 FXDIB_8bppCmyka = 0x608,
22 FXDIB_Rgb = 0x018,
23 FXDIB_Rgba = 0x218,
24 FXDIB_Rgb32 = 0x020,
25 FXDIB_Argb = 0x220,
26 FXDIB_Cmyk = 0x420,
27 FXDIB_Cmyka = 0x620,
28 };
29 enum FXDIB_Channel {
30 FXDIB_Red = 1,
31 FXDIB_Green,
32 FXDIB_Blue,
33 FXDIB_Cyan,
34 FXDIB_Magenta,
35 FXDIB_Yellow,
36 FXDIB_Black,
37 FXDIB_Alpha
38 };
39 #define FXDIB_DOWNSAMPLE 0x04
40 #define FXDIB_INTERPOL 0x20
41 #define FXDIB_BICUBIC_INTERPOL 0x80
42 #define FXDIB_NOSMOOTH 0x100
43 #define FXDIB_PALETTE_LOC 0x01
44 #define FXDIB_PALETTE_WIN 0x02
45 #define FXDIB_PALETTE_MAC 0x04
46 #define FXDIB_BLEND_NORMAL 0
47 #define FXDIB_BLEND_MULTIPLY 1
48 #define FXDIB_BLEND_SCREEN 2
49 #define FXDIB_BLEND_OVERLAY 3
50 #define FXDIB_BLEND_DARKEN 4
51 #define FXDIB_BLEND_LIGHTEN 5
52
53 #define FXDIB_BLEND_COLORDODGE 6
54 #define FXDIB_BLEND_COLORBURN 7
55 #define FXDIB_BLEND_HARDLIGHT 8
56 #define FXDIB_BLEND_SOFTLIGHT 9
57 #define FXDIB_BLEND_DIFFERENCE 10
58 #define FXDIB_BLEND_EXCLUSION 11
59 #define FXDIB_BLEND_NONSEPARABLE 21
60 #define FXDIB_BLEND_HUE 21
61 #define FXDIB_BLEND_SATURATION 22
62 #define FXDIB_BLEND_COLOR 23
63 #define FXDIB_BLEND_LUMINOSITY 24
64 #define FXDIB_BLEND_UNSUPPORTED -1
65 typedef FX_DWORD FX_ARGB;
66 typedef FX_DWORD FX_COLORREF;
67 typedef FX_DWORD FX_CMYK;
68 class CFX_ClipRgn;
69 class CFX_DIBSource;
70 class CFX_DIBitmap;
71 #define FXSYS_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
72 #define FXSYS_GetRValue(rgb) ((rgb) & 0xff)
73 #define FXSYS_GetGValue(rgb) (((rgb) >> 8) & 0xff)
74 #define FXSYS_GetBValue(rgb) (((rgb) >> 16) & 0xff)
75 #define FX_CCOLOR(val) (255-(val))
76 #define FXSYS_CMYK(c, m, y, k) (((c) << 24) | ((m) << 16) | ((y) << 8) | (k))
77 #define FXSYS_GetCValue(cmyk) ((FX_BYTE)((cmyk) >> 24) & 0xff)
78 #define FXSYS_GetMValue(cmyk) ((FX_BYTE)((cmyk) >> 16) & 0xff)
79 #define FXSYS_GetYValue(cmyk) ((FX_BYTE)((cmyk) >> 8) & 0xff)
80 #define FXSYS_GetKValue(cmyk) ((FX_BYTE)(cmyk) & 0xff)
81 void CmykDecode(FX_CMYK cmyk, int& c, int& m, int& y, int& k);
CmykEncode(int c,int m,int y,int k)82 inline FX_CMYK CmykEncode(int c, int m, int y, int k)
83 {
84 return (c << 24) | (m << 16) | (y << 8) | k;
85 }
86 void ArgbDecode(FX_ARGB argb, int& a, int& r, int&g, int& b);
87 void ArgbDecode(FX_ARGB argb, int& a, FX_COLORREF& rgb);
ArgbEncode(int a,int r,int g,int b)88 inline FX_ARGB ArgbEncode(int a, int r, int g, int b)
89 {
90 return (a << 24) | (r << 16) | (g << 8) | b;
91 }
92 FX_ARGB ArgbEncode(int a, FX_COLORREF rgb);
93 #define FXARGB_A(argb) ((FX_BYTE)((argb) >> 24))
94 #define FXARGB_R(argb) ((FX_BYTE)((argb) >> 16))
95 #define FXARGB_G(argb) ((FX_BYTE)((argb) >> 8))
96 #define FXARGB_B(argb) ((FX_BYTE)(argb))
97 #define FXARGB_MAKE(a,r,g,b) (((FX_DWORD)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
98 #define FXARGB_MUL_ALPHA(argb, alpha) (((((argb) >> 24) * (alpha) / 255) << 24) | ((argb) & 0xffffff))
99 #define FXRGB2GRAY(r,g,b) (((b) * 11 + (g) * 59 + (r) * 30) / 100)
100 #define FXCMYK2GRAY(c,m,y,k) (((255-(c)) * (255-(k)) * 30 + (255-(m)) * (255-(k)) * 59 + (255-(y)) * (255-(k)) * 11) / 25500)
101 #define FXDIB_ALPHA_MERGE(backdrop, source, source_alpha) (((backdrop) * (255-(source_alpha)) + (source)*(source_alpha))/255)
102 #define FXDIB_ALPHA_UNION(dest, src) ((dest) + (src) - (dest)*(src)/255)
103 #define FXCMYK_GETDIB(p) ((((FX_LPBYTE)(p))[0] << 24 | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | ((FX_LPBYTE)(p))[3]))
104 #define FXCMYK_SETDIB(p, cmyk) ((FX_LPBYTE)(p))[0] = (FX_BYTE)((cmyk) >> 24), \
105 ((FX_LPBYTE)(p))[1] = (FX_BYTE)((cmyk) >> 16), \
106 ((FX_LPBYTE)(p))[2] = (FX_BYTE)((cmyk) >> 8), \
107 ((FX_LPBYTE)(p))[3] = (FX_BYTE)(cmyk))
108 #define FXARGB_GETDIB(p) ((((FX_LPBYTE)(p))[0]) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[3] << 24))
109 #define FXARGB_SETDIB(p, argb) ((FX_LPBYTE)(p))[0] = (FX_BYTE)(argb), \
110 ((FX_LPBYTE)(p))[1] = (FX_BYTE)((argb) >> 8), \
111 ((FX_LPBYTE)(p))[2] = (FX_BYTE)((argb) >> 16), \
112 ((FX_LPBYTE)(p))[3] = (FX_BYTE)((argb) >> 24)
113 #define FXARGB_COPY(dest, src) *(FX_LPBYTE)(dest) = *(FX_LPBYTE)(src), \
114 *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
115 *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src)+2), \
116 *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3)
117 #define FXCMYK_COPY(dest, src) *(FX_LPBYTE)(dest) = *(FX_LPBYTE)(src), \
118 *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
119 *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src)+2), \
120 *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3)
121 #define FXARGB_SETRGBORDERDIB(p, argb) ((FX_LPBYTE)(p))[3] = (FX_BYTE)(argb>>24), \
122 ((FX_LPBYTE)(p))[0] = (FX_BYTE)((argb) >> 16), \
123 ((FX_LPBYTE)(p))[1] = (FX_BYTE)((argb) >> 8), \
124 ((FX_LPBYTE)(p))[2] = (FX_BYTE)(argb)
125 #define FXARGB_GETRGBORDERDIB(p) (((FX_LPBYTE)(p))[2]) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0] << 16) | (((FX_LPBYTE)(p))[3] << 24)
126 #define FXARGB_RGBORDERCOPY(dest, src) *((FX_LPBYTE)(dest)+3) = *((FX_LPBYTE)(src)+3), \
127 *(FX_LPBYTE)(dest) = *((FX_LPBYTE)(src)+2), \
128 *((FX_LPBYTE)(dest)+1) = *((FX_LPBYTE)(src)+1), \
129 *((FX_LPBYTE)(dest)+2) = *((FX_LPBYTE)(src))
130 #define FXARGB_TODIB(argb) (argb)
131 #define FXCMYK_TODIB(cmyk) ((FX_BYTE)((cmyk) >> 24) | ((FX_BYTE)((cmyk) >> 16)) << 8 | ((FX_BYTE)((cmyk) >> 8)) << 16 | ((FX_BYTE)(cmyk) << 24))
132 #define FXARGB_TOBGRORDERDIB(argb) ((FX_BYTE)(argb>>16) | ((FX_BYTE)(argb>>8)) << 8 | ((FX_BYTE)(argb)) << 16 | ((FX_BYTE)(argb>>24) << 24))
133 #define FXGETFLAG_COLORTYPE(flag) (FX_BYTE)((flag)>>8)
134 #define FXGETFLAG_ALPHA_FILL(flag) (FX_BYTE)(flag)
135 #define FXGETFLAG_ALPHA_STROKE(flag) (FX_BYTE)((flag)>>16)
136 #define FXSETFLAG_COLORTYPE(flag, val) flag = (((val)<<8)|(flag&0xffff00ff))
137 #define FXSETFLAG_ALPHA_FILL(flag, val) flag = ((val)|(flag&0xffffff00))
138 #define FXSETFLAG_ALPHA_STROKE(flag, val) flag = (((val)<<16)|(flag&0xff00ffff))
139 class CFX_DIBSource
140 {
141 public:
142
143 virtual ~CFX_DIBSource();
144
145
146
GetWidth()147 int GetWidth() const
148 {
149 return m_Width;
150 }
151
GetHeight()152 int GetHeight() const
153 {
154 return m_Height;
155 }
156
GetFormat()157 FXDIB_Format GetFormat() const
158 {
159 return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp);
160 }
161
GetPitch()162 FX_DWORD GetPitch() const
163 {
164 return m_Pitch;
165 }
166
GetPalette()167 FX_DWORD* GetPalette() const
168 {
169 return m_pPalette;
170 }
171
172
173
GetBuffer()174 virtual FX_LPBYTE GetBuffer() const
175 {
176 return NULL;
177 }
178
179 virtual FX_LPCBYTE GetScanline(int line) const = 0;
180
SkipToScanline(int line,IFX_Pause * pPause)181 virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const
182 {
183 return FALSE;
184 }
185
186 virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
187 int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const = 0;
188
SetDownSampleSize(int width,int height)189 virtual void SetDownSampleSize(int width, int height) const {}
190
GetBPP()191 int GetBPP() const
192 {
193 return m_bpp;
194 }
195
IsAlphaMask()196 FX_BOOL IsAlphaMask() const
197 {
198 return m_AlphaFlag == 1;
199 }
200
HasAlpha()201 FX_BOOL HasAlpha() const
202 {
203 return m_AlphaFlag & 2 ? TRUE : FALSE;
204 }
205
IsOpaqueImage()206 FX_BOOL IsOpaqueImage() const
207 {
208 return !(m_AlphaFlag & 3);
209 }
210
IsCmykImage()211 FX_BOOL IsCmykImage() const
212 {
213 return m_AlphaFlag & 4 ? TRUE : FALSE;
214 }
215
216
217
GetPaletteSize()218 int GetPaletteSize() const
219 {
220 return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));
221 }
222
223 FX_DWORD GetPaletteEntry(int index) const;
224
225 void SetPaletteEntry(int index, FX_DWORD color);
GetPaletteArgb(int index)226 FX_DWORD GetPaletteArgb(int index) const
227 {
228 return GetPaletteEntry(index);
229 }
SetPaletteArgb(int index,FX_DWORD color)230 void SetPaletteArgb(int index, FX_DWORD color)
231 {
232 SetPaletteEntry(index, color);
233 }
234
235 void CopyPalette(const FX_DWORD* pSrcPal, FX_DWORD size = 256);
236
237
238 CFX_DIBitmap* Clone(const FX_RECT* pClip = NULL) const;
239
240 CFX_DIBitmap* CloneConvert(FXDIB_Format format, const FX_RECT* pClip = NULL, void* pIccTransform = NULL) const;
241
242 CFX_DIBitmap* StretchTo(int dest_width, int dest_height, FX_DWORD flags = 0, const FX_RECT* pClip = NULL) const;
243
244
245 CFX_DIBitmap* TransformTo(const CFX_AffineMatrix* pMatrix, int& left, int &top,
246 FX_DWORD flags = 0, const FX_RECT* pClip = NULL) const;
247
248 CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = NULL) const;
249
250 FX_BOOL CopyAlphaMask(const CFX_DIBSource* pAlphaMask, const FX_RECT* pClip = NULL);
251
252 CFX_DIBitmap* SwapXY(FX_BOOL bXFlip, FX_BOOL bYFlip, const FX_RECT* pClip = NULL) const;
253
254 CFX_DIBitmap* FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const;
255
256 void GetOverlapRect(int& dest_left, int& dest_top, int& width, int& height, int src_width,
257 int src_height, int& src_left, int& src_top, const CFX_ClipRgn* pClipRgn);
258
259 CFX_DIBitmap* m_pAlphaMask;
260 protected:
261
262 CFX_DIBSource();
263
264 int m_Width;
265
266 int m_Height;
267
268 int m_bpp;
269
270 FX_DWORD m_AlphaFlag;
271
272 FX_DWORD m_Pitch;
273
274 FX_DWORD* m_pPalette;
275
276 void BuildPalette();
277
278 FX_BOOL BuildAlphaMask();
279
280 int FindPalette(FX_DWORD color) const;
281
282 void GetPalette(FX_DWORD* pal, int alpha) const;
283 };
284 class CFX_DIBitmap : public CFX_DIBSource
285 {
286 public:
287
288 virtual ~CFX_DIBitmap();
289
290 CFX_DIBitmap();
291
292 CFX_DIBitmap(const CFX_DIBitmap& src);
293
294 FX_BOOL Create(int width, int height, FXDIB_Format format, FX_LPBYTE pBuffer = NULL, int pitch = 0);
295
296 FX_BOOL Copy(const CFX_DIBSource* pSrc);
297
GetBuffer()298 virtual FX_LPBYTE GetBuffer() const
299 {
300 return m_pBuffer;
301 }
302
GetScanline(int line)303 virtual FX_LPCBYTE GetScanline(int line) const
304 {
305 return m_pBuffer ? m_pBuffer + line * m_Pitch : NULL;
306 }
307
308 virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
309 int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
310
311 void TakeOver(CFX_DIBitmap* pSrcBitmap);
312
313 FX_BOOL ConvertFormat(FXDIB_Format format, void* pIccTransform = NULL);
314
315 void Clear(FX_DWORD color);
316
317 FX_DWORD GetPixel(int x, int y) const;
318
319 void SetPixel(int x, int y, FX_DWORD color);
320
321 FX_BOOL LoadChannel(FXDIB_Channel destChannel, const CFX_DIBSource* pSrcBitmap, FXDIB_Channel srcChannel);
322
323 FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value);
324
325 FX_BOOL MultiplyAlpha(int alpha);
326
327 FX_BOOL MultiplyAlpha(const CFX_DIBSource* pAlphaMask);
328
329 FX_BOOL TransferBitmap(int dest_left, int dest_top, int width, int height,
330 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top, void* pIccTransform = NULL);
331
332 FX_BOOL CompositeBitmap(int dest_left, int dest_top, int width, int height,
333 const CFX_DIBSource* pSrcBitmap, int src_left, int src_top,
334 int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = NULL, FX_BOOL bRgbByteOrder = FALSE, void* pIccTransform = NULL);
335
336 FX_BOOL TransferMask(int dest_left, int dest_top, int width, int height,
337 const CFX_DIBSource* pMask, FX_DWORD color, int src_left, int src_top, int alpha_flag = 0, void* pIccTransform = NULL);
338
339 FX_BOOL CompositeMask(int dest_left, int dest_top, int width, int height,
340 const CFX_DIBSource* pMask, FX_DWORD color, int src_left, int src_top,
341 int blend_type = FXDIB_BLEND_NORMAL, const CFX_ClipRgn* pClipRgn = NULL, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL);
342
343 FX_BOOL CompositeRect(int dest_left, int dest_top, int width, int height, FX_DWORD color, int alpha_flag = 0, void* pIccTransform = NULL);
344
345 FX_BOOL ConvertColorScale(FX_DWORD forecolor, FX_DWORD backcolor);
346
347 FX_BOOL DitherFS(const FX_DWORD* pPalette, int pal_size, const FX_RECT* pRect = NULL);
348 protected:
349
350 FX_LPBYTE m_pBuffer;
351
352 FX_BOOL m_bExtBuf;
353
354 FX_BOOL GetGrayData(void* pIccTransform = NULL);
355 };
356 class CFX_DIBExtractor
357 {
358 public:
359
360 CFX_DIBExtractor(const CFX_DIBSource* pSrc);
361
362 ~CFX_DIBExtractor();
363
364 operator CFX_DIBitmap*()
365 {
366 return m_pBitmap;
367 }
368 private:
369
370 CFX_DIBitmap* m_pBitmap;
371 };
372 typedef CFX_CountRef<CFX_DIBitmap> CFX_DIBitmapRef;
373 class CFX_FilteredDIB : public CFX_DIBSource
374 {
375 public:
376
377 CFX_FilteredDIB();
378
379 ~CFX_FilteredDIB();
380
381 void LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc = FALSE);
382
383 virtual FXDIB_Format GetDestFormat() = 0;
384
385 virtual FX_DWORD* GetDestPalette() = 0;
386
387
388 virtual void TranslateScanline(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf) const = 0;
389
390 virtual void TranslateDownSamples(FX_LPBYTE dest_buf, FX_LPCBYTE src_buf, int pixels, int Bpp) const = 0;
391 protected:
392 virtual FX_LPCBYTE GetScanline(int line) const;
393 virtual void DownSampleScanline(int line, FX_LPBYTE dest_scan, int dest_bpp,
394 int dest_width, FX_BOOL bFlipX, int clip_left, int clip_width) const;
395
396 const CFX_DIBSource* m_pSrc;
397
398 FX_BOOL m_bAutoDropSrc;
399
400 FX_LPBYTE m_pScanline;
401 };
402 class IFX_ScanlineComposer
403 {
404 public:
~IFX_ScanlineComposer()405 virtual ~IFX_ScanlineComposer() { }
406
407 virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha = NULL) = 0;
408
409 virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette) = 0;
410 };
411 class CFX_ScanlineCompositor
412 {
413 public:
414 CFX_ScanlineCompositor();
415
416 ~CFX_ScanlineCompositor();
417
418 FX_BOOL Init(FXDIB_Format dest_format, FXDIB_Format src_format, FX_INT32 width, FX_DWORD* pSrcPalette,
419 FX_DWORD mask_color, int blend_type, FX_BOOL bClip, FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL);
420
421
422 void CompositeRgbBitmapLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width, FX_LPCBYTE clip_scan,
423 FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
424
425
426 void CompositePalBitmapLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan,
427 FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
428
429
430 void CompositeByteMaskLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int width, FX_LPCBYTE clip_scan,
431 FX_LPBYTE dst_extra_alpha = NULL);
432
433
434 void CompositeBitMaskLine(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int src_left, int width, FX_LPCBYTE clip_scan,
435 FX_LPBYTE dst_extra_alpha = NULL);
436 protected:
437 int m_Transparency;
438 FXDIB_Format m_SrcFormat,
439 m_DestFormat;
440 FX_DWORD* m_pSrcPalette;
441
442 int m_MaskAlpha,
443 m_MaskRed,
444 m_MaskGreen,
445 m_MaskBlue,
446 m_MaskBlack;
447 int m_BlendType;
448 void* m_pIccTransform;
449 FX_LPBYTE m_pCacheScanline;
450 int m_CacheSize;
451 FX_BOOL m_bRgbByteOrder;
452 };
453 class CFX_BitmapComposer : public IFX_ScanlineComposer
454 {
455 public:
456
457 CFX_BitmapComposer();
458
459 ~CFX_BitmapComposer();
460
461
462 void Compose(CFX_DIBitmap* pDest, const CFX_ClipRgn* pClipRgn, int bitmap_alpha,
463 FX_DWORD mask_color, FX_RECT& dest_rect, FX_BOOL bVertical,
464 FX_BOOL bFlipX, FX_BOOL bFlipY, FX_BOOL bRgbByteOrder = FALSE,
465 int alpha_flag = 0, void* pIccTransform = NULL, int blend_type = FXDIB_BLEND_NORMAL);
466
467 virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette);
468
469
470 virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha);
471 protected:
472
473 void DoCompose(FX_LPBYTE dest_scan, FX_LPCBYTE src_scan, int dest_width, FX_LPCBYTE clip_scan,
474 FX_LPCBYTE src_extra_alpha = NULL, FX_LPBYTE dst_extra_alpha = NULL);
475 CFX_DIBitmap* m_pBitmap;
476 const CFX_ClipRgn* m_pClipRgn;
477 FXDIB_Format m_SrcFormat;
478 int m_DestLeft, m_DestTop, m_DestWidth, m_DestHeight, m_BitmapAlpha;
479 FX_DWORD m_MaskColor;
480 const CFX_DIBitmap* m_pClipMask;
481 CFX_ScanlineCompositor m_Compositor;
482 FX_BOOL m_bVertical, m_bFlipX, m_bFlipY;
483 int m_AlphaFlag;
484 void* m_pIccTransform;
485 FX_BOOL m_bRgbByteOrder;
486 int m_BlendType;
487 void ComposeScanlineV(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha = NULL);
488 FX_LPBYTE m_pScanlineV, m_pClipScanV, m_pAddClipScan, m_pScanlineAlphaV;
489 };
490 class CFX_BitmapStorer : public IFX_ScanlineComposer
491 {
492 public:
493
494 CFX_BitmapStorer();
495
496 ~CFX_BitmapStorer();
497
498 virtual void ComposeScanline(int line, FX_LPCBYTE scanline, FX_LPCBYTE scan_extra_alpha);
499
500 virtual FX_BOOL SetInfo(int width, int height, FXDIB_Format src_format, FX_DWORD* pSrcPalette);
501
GetBitmap()502 CFX_DIBitmap* GetBitmap()
503 {
504 return m_pBitmap;
505 }
506
507 CFX_DIBitmap* Detach();
508
509 void Replace(CFX_DIBitmap* pBitmap);
510 private:
511 CFX_DIBitmap* m_pBitmap;
512 };
513 class CStretchEngine;
514 class CFX_ImageStretcher
515 {
516 public:
517
518 CFX_ImageStretcher();
519
520 ~CFX_ImageStretcher();
521
522 FX_INT32 Start(IFX_ScanlineComposer* pDest, const CFX_DIBSource* pBitmap,
523 int dest_width, int dest_height, const FX_RECT& bitmap_rect, FX_DWORD flags);
524
525
526 FX_INT32 Continue(IFX_Pause* pPause);
527 IFX_ScanlineComposer* m_pDest;
528 const CFX_DIBSource* m_pSource;
529 CStretchEngine* m_pStretchEngine;
530 FX_DWORD m_Flags;
531 FX_BOOL m_bFlipX,
532 m_bFlipY;
533 int m_DestWidth,
534 m_DestHeight;
535 FX_RECT m_ClipRect;
536 int m_LineIndex;
537 int m_DestBPP;
538 FX_LPBYTE m_pScanline;
539 FX_LPBYTE m_pMaskScanline;
540 FXDIB_Format m_DestFormat;
541 FX_INT32 m_Status;
542
543 FX_INT32 StartQuickStretch();
544
545 FX_INT32 StartStretch();
546
547 FX_INT32 ContinueQuickStretch(IFX_Pause* pPause);
548
549 FX_INT32 ContinueStretch(IFX_Pause* pPause);
550 };
551 class CFX_ImageTransformer
552 {
553 public:
554
555 CFX_ImageTransformer();
556
557 ~CFX_ImageTransformer();
558
559 FX_INT32 Start(const CFX_DIBSource* pSrc, const CFX_AffineMatrix* pMatrix, int flags, const FX_RECT* pClip);
560
561
562 FX_INT32 Continue(IFX_Pause* pPause);
563 CFX_AffineMatrix* m_pMatrix;
564 FX_RECT m_StretchClip;
565 int m_ResultLeft, m_ResultTop, m_ResultWidth, m_ResultHeight;
566 CFX_AffineMatrix m_dest2stretch;
567 CFX_ImageStretcher m_Stretcher;
568 CFX_BitmapStorer m_Storer;
569 FX_DWORD m_Flags;
570 int m_Status;
571 };
572 class CFX_ImageRenderer
573 {
574 public:
575
576 CFX_ImageRenderer();
577
578 ~CFX_ImageRenderer();
579
580 FX_INT32 Start(CFX_DIBitmap* pDevice, const CFX_ClipRgn* pClipRgn,
581 const CFX_DIBSource* pSource, int bitmap_alpha,
582 FX_DWORD mask_color, const CFX_AffineMatrix* pMatrix, FX_DWORD dib_flags,
583 FX_BOOL bRgbByteOrder = FALSE, int alpha_flag = 0, void* pIccTransform = NULL,
584 int blend_type = FXDIB_BLEND_NORMAL);
585
586 FX_INT32 Continue(IFX_Pause* pPause);
587 protected:
588 CFX_DIBitmap* m_pDevice;
589 const CFX_ClipRgn* m_pClipRgn;
590 int m_BitmapAlpha;
591 FX_DWORD m_MaskColor;
592 CFX_AffineMatrix m_Matrix;
593 CFX_ImageTransformer* m_pTransformer;
594 CFX_ImageStretcher m_Stretcher;
595 CFX_BitmapComposer m_Composer;
596 int m_Status;
597 int m_DestLeft, m_DestTop;
598 FX_RECT m_ClipBox;
599 FX_DWORD m_Flags;
600 int m_AlphaFlag;
601 void* m_pIccTransform;
602 FX_BOOL m_bRgbByteOrder;
603 int m_BlendType;
604 };
605
606 #endif // CORE_INCLUDE_FXGE_FX_DIB_H_
607