ref: 35576bf067624e18397e3a72148b82c7cf3b849b
parent: 2f52df4a0dd1bfeb645c12b28f27970549acd809
author: Alexei Podtelezhnikov <[email protected]>
date: Fri Jul 11 18:40:34 EDT 2014
[base] Clean up bitmap conversion. * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use appropriate FT_DivFix and remove superfluous upscaling.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-07-11 Alexei Podtelezhnikov <[email protected]>
+
+ [base] Clean up bitmap conversion.
+
+ * src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
+ appropriate FT_DivFix and remove superfluous upscaling.
+
2014-07-04 Alexei Podtelezhnikov <[email protected]>
[base] Small optimization of the ancient code.
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -401,10 +401,9 @@
*/
/* Undo premultification, get the number in a 16.16 form. */
- b = FT_MulDiv( b, 65536, a );
- g = FT_MulDiv( g, 65536, a );
- r = FT_MulDiv( r, 65536, a );
- a = a * 256;
+ b = FT_DivFix( b, a );
+ g = FT_DivFix( g, a );
+ r = FT_DivFix( r, a );
/* Apply gamma of 2.0 instead of 2.2. */
b = FT_MulFix( b, b );
@@ -425,10 +424,10 @@
* - If alpha is zero and luminosity is zero, we want 255.
* - If alpha is zero and luminosity is one, we want 0.
*
- * So the formula is a * (1 - l).
+ * So the formula is a * (1 - l) = a - l * a.
*/
- return (FT_Byte)( FT_MulFix( 65535 - l, a ) >> 8 );
+ return a - (FT_Byte)FT_MulFix( l, a );
}