20 #include FT_INTERNAL_DEBUG_H 22 #include FT_LCD_FILTER_H 24 #include FT_INTERNAL_OBJECTS_H 27 #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING 56 fir[0] = weights[2] * val1;
57 fir[1] = weights[3] * val1;
58 fir[2] = weights[4] * val1;
63 fir[0] += weights[1] * val1;
64 fir[1] += weights[2] * val1;
65 fir[2] += weights[3] * val1;
66 fir[3] += weights[4] * val1;
68 for ( xx = 2; xx <
width; xx++ )
74 pix = fir[0] + weights[0] *
val;
75 fir[0] = fir[1] + weights[1] *
val;
76 fir[1] = fir[2] + weights[2] *
val;
77 fir[2] = fir[3] + weights[3] *
val;
78 fir[3] = weights[4] *
val;
107 for ( ; width > 0; width--, column++ )
115 fir[0] = weights[2] * val1;
116 fir[1] = weights[3] * val1;
117 fir[2] = weights[4] * val1;
123 fir[0] += weights[1] * val1;
124 fir[1] += weights[2] * val1;
125 fir[2] += weights[3] * val1;
126 fir[3] += weights[4] * val1;
129 for ( yy = 2; yy <
height; yy++ )
135 pix = fir[0] + weights[0] *
val;
136 fir[0] = fir[1] + weights[1] *
val;
137 fir[1] = fir[2] + weights[2] *
val;
138 fir[2] = fir[3] + weights[3] *
val;
139 fir[3] = weights[4] *
val;
142 pix |= -( pix >> 8 );
143 col[-2 * pitch] = (
FT_Byte)pix;
152 pix |= -( pix >> 8 );
153 col[-2 * pitch] = (
FT_Byte)pix;
156 pix |= -( pix >> 8 );
168 _ft_lcd_filter_legacy(
FT_Bitmap* bitmap,
176 static const int filters[3][3] =
178 { 65538 * 9/13, 65538 * 1/6, 65538 * 1/13 },
179 { 65538 * 3/13, 65538 * 4/6, 65538 * 3/13 },
180 { 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 }
197 for ( xx = 0; xx <
width; xx += 3 )
206 r += filters[0][0] *
p;
207 g += filters[0][1] *
p;
208 b += filters[0][2] *
p;
211 r += filters[1][0] *
p;
212 g += filters[1][1] *
p;
213 b += filters[1][2] *
p;
216 r += filters[2][0] *
p;
217 g += filters[2][1] *
p;
218 b += filters[2][2] *
p;
220 line[xx] = (
FT_Byte)( r / 65536 );
221 line[xx + 1] = (
FT_Byte)( g / 65536 );
222 line[xx + 2] = (
FT_Byte)( b / 65536 );
231 for ( ; width > 0; width--, column++ )
237 for ( ; col < col_end; col += 3 * pitch )
246 r += filters[0][0] *
p;
247 g += filters[0][1] *
p;
248 b += filters[0][2] *
p;
251 r += filters[1][0] *
p;
252 g += filters[1][1] *
p;
253 b += filters[1][2] *
p;
256 r += filters[2][0] *
p;
257 g += filters[2][1] *
p;
258 b += filters[2][2] *
p;
260 col[0] = (
FT_Byte)( r / 65536 );
261 col[pitch] = (
FT_Byte)( g / 65536 );
262 col[2 * pitch] = (
FT_Byte)( b / 65536 );
273 unsigned char *weights )
275 if ( !library || !weights )
276 return FT_THROW( Invalid_Argument );
278 ft_memcpy( library->lcd_weights, weights, 5 );
288 static const FT_Byte light_filter[5] =
289 { 0x00, 0x55, 0x56, 0x55, 0x00 };
292 static const FT_Byte default_filter[5] =
293 { 0x10, 0x40, 0x70, 0x40, 0x10 };
297 return FT_THROW( Invalid_Argument );
302 library->lcd_filter_func =
NULL;
303 library->lcd_extra = 0;
307 #if defined( FT_FORCE_LEGACY_LCD_FILTER ) 309 library->lcd_filter_func = _ft_lcd_filter_legacy;
310 library->lcd_extra = 0;
312 #elif defined( FT_FORCE_LIGHT_LCD_FILTER ) 314 ft_memcpy( library->lcd_weights, light_filter, 5 );
315 library->lcd_filter_func = _ft_lcd_filter_fir;
316 library->lcd_extra = 2;
320 ft_memcpy( library->lcd_weights, default_filter, 5 );
321 library->lcd_filter_func = _ft_lcd_filter_fir;
322 library->lcd_extra = 2;
329 ft_memcpy( library->lcd_weights, light_filter, 5 );
330 library->lcd_filter_func = _ft_lcd_filter_fir;
331 library->lcd_extra = 2;
337 library->lcd_filter_func = _ft_lcd_filter_legacy;
338 library->lcd_extra = 0;
344 return FT_THROW( Invalid_Argument );
347 library->lcd_filter =
filter;
356 unsigned char *weights )
361 return FT_THROW( Unimplemented_Feature );
372 return FT_THROW( Unimplemented_Feature );
GLint GLint GLsizei GLsizei height
enum FT_Render_Mode_ FT_Render_Mode
FT_Library_SetLcdFilterWeights(FT_Library library, unsigned char *weights)
return FT_THROW(Missing_Property)
GLint GLint GLsizei width
GLboolean GLboolean GLboolean b
GLdouble GLdouble GLdouble r
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
FT_BEGIN_HEADER enum FT_LcdFilter_ FT_LcdFilter
GLenum GLenum GLvoid GLvoid * column
FT_Library_SetLcdFilter(FT_Library library, FT_LcdFilter filter)