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