本文主要是介绍[开源]Qt图片调整之亮度调节,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
原理:
获取图片像素点RGB分量值,直接加上亮度值。
QImage AdjustBrightness(QImage Img, int iBrightValue)
{int red, green, blue;int pixels = Img.width() * Img.height();unsigned int *data = (unsigned int *)Img.bits();for (int i = 0; i < pixels; ++i){red= qRed(data[i])+ iBrightValue;red = (red < 0x00) ? 0x00 : (red > 0xff) ? 0xff : red;green= qGreen(data[i]) + iBrightValue;green = (green < 0x00) ? 0x00 : (green > 0xff) ? 0xff : green;blue= qBlue(data[i]) + iBrightValue;blue = (blue < 0x00) ? 0x00 : (blue > 0xff) ? 0xff : blue ;data[i] = qRgba(red, green, blue, qAlpha(data[i]));}return Img;
}
这篇关于[开源]Qt图片调整之亮度调节的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!