OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftlcdfil.h */ | 3 /* ftlcdfil.h */ |
4 /* */ | 4 /* */ |
5 /* FreeType API for color filtering of subpixel bitmap glyphs */ | 5 /* FreeType API for color filtering of subpixel bitmap glyphs */ |
6 /* (specification). */ | 6 /* (specification). */ |
7 /* */ | 7 /* */ |
8 /* Copyright 2006, 2007, 2008, 2010 by */ | 8 /* Copyright 2006, 2007, 2008, 2010 by */ |
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
10 /* */ | 10 /* */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 * @description: | 46 * @description: |
47 * The @FT_Library_SetLcdFilter API can be used to specify a low-pass | 47 * The @FT_Library_SetLcdFilter API can be used to specify a low-pass |
48 * filter which is then applied to LCD-optimized bitmaps generated | 48 * filter which is then applied to LCD-optimized bitmaps generated |
49 * through @FT_Render_Glyph. This is useful to reduce color fringes | 49 * through @FT_Render_Glyph. This is useful to reduce color fringes |
50 * which would occur with unfiltered rendering. | 50 * which would occur with unfiltered rendering. |
51 * | 51 * |
52 * Note that no filter is active by default, and that this function is | 52 * Note that no filter is active by default, and that this function is |
53 * *not* implemented in default builds of the library. You need to | 53 * *not* implemented in default builds of the library. You need to |
54 * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file | 54 * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file |
55 * in order to activate it. | 55 * in order to activate it. |
| 56 * |
| 57 * FreeType generates alpha coverage maps, which are linear by nature. |
| 58 * For instance, the value 0x80 in bitmap representation means that |
| 59 * (within numerical precision) 0x80/0xff fraction of that pixel is |
| 60 * covered by the glyph's outline. The blending function for placing |
| 61 * text over a background is |
| 62 * |
| 63 * { |
| 64 * dst = alpha * src + (1 - alpha) * dst , |
| 65 * } |
| 66 * |
| 67 * which is known as OVER. However, when calculating the output of the |
| 68 * OVER operator, the source colors should first be transformed to a |
| 69 * linear color space, then alpha blended in that space, and transformed |
| 70 * back to the output color space. |
| 71 * |
| 72 * When linear light blending is used, the default FIR5 filtering |
| 73 * weights (as given by FT_LCD_FILTER_DEFAULT) are no longer optimal, as |
| 74 * they have been designed for black on white rendering while lacking |
| 75 * gamma correction. To preserve color neutrality, weights for a FIR5 |
| 76 * filter should be chosen according to two free parameters `a' and `c', |
| 77 * and the FIR weights should be |
| 78 * |
| 79 * { |
| 80 * [a - c, a + c, 2 * a, a + c, a - c] . |
| 81 * } |
| 82 * |
| 83 * This formula generates equal weights for all the color primaries |
| 84 * across the filter kernel, which makes it colorless. One suggested |
| 85 * set of weights is |
| 86 * |
| 87 * { |
| 88 * [0x10, 0x50, 0x60, 0x50, 0x10] , |
| 89 * } |
| 90 * |
| 91 * where `a' has value 0x30 and `b' value 0x20. The weights in filter |
| 92 * may have a sum larger than 0x100, which increases coloration slightly |
| 93 * but also improves contrast. |
56 */ | 94 */ |
57 | 95 |
58 | 96 |
59 /**************************************************************************** | 97 /**************************************************************************** |
60 * | 98 * |
61 * @enum: | 99 * @enum: |
62 * FT_LcdFilter | 100 * FT_LcdFilter |
63 * | 101 * |
64 * @description: | 102 * @description: |
65 * A list of values to identify various types of LCD filters. | 103 * A list of values to identify various types of LCD filters. |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 242 |
205 /* */ | 243 /* */ |
206 | 244 |
207 | 245 |
208 FT_END_HEADER | 246 FT_END_HEADER |
209 | 247 |
210 #endif /* __FT_LCD_FILTER_H__ */ | 248 #endif /* __FT_LCD_FILTER_H__ */ |
211 | 249 |
212 | 250 |
213 /* END */ | 251 /* END */ |
OLD | NEW |