# how to adjust the alpha value

## how to adjust the alpha value

My program need to adjust the alpha value of a image by increasing or decreasing some percent,such as increase 15% alpha,the new value is 1.15*alpha.But which function in IPP can implement it?

2 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

pango,

I'm assuming RGBA and Ipp8u data.

You might tryippiMulC_8u_C4RSfs.It will only work if you can express the factor as a fraction with a 2^n denominator. Use {1.0, 1.0, 1.0, factor*scale} as the value.

For example, for MulC, you can use {1.0, 1.0, 1.0, 147} with a scaleFactor of 7 (so the scale is 2^7=128). This should multiply the alpha channel by 1.148.

You'll have to determine whether the extra 3 multiplications by 1.0 still result in a performance increase. It's not easy to multiply every fourth value efficientlyusing SIMD.

I came up with a bunch oftricks like this in the IPP book, although I did find that frequently it took some work and tweaking to get a performance gain.

Stewart