QImage Bright1(QImage &image,int brightness)
{
uchar *line =image.scanLine(0);
uchar *pixel = line;
for (int y = 0; y < image.height(); ++y)
{
pixel = line;
for (int x = 0; x < image.width(); ++x)
{
*pixel = qBound(0, *pixel + brightness, 255);
*(pixel + 1) = qBound(0, *(pixel + 1) + brightness, 255);
*(pixel + 2) = qBound(0, *(pixel + 2) + brightness, 255);
pixel += 4;
}
line += image.bytesPerLine();
}
return image;
}
QImage Bright2(QImage &image,int brightness)
{
QImage origin = image;
QColor oldColor;
int delta = brightness;
int r=0,g=0,b=0;
uchar *line =image.scanLine(0);
uchar *pixel
Qt 改变图片亮度算法
最新推荐文章于 2024-07-09 17:44:19 发布
本文介绍了使用Qt库改变图片亮度的三种不同实现方式:Bright1、Bright2和Bright3。每个方法通过遍历像素并调整红色、绿色和蓝色分量来实现亮度的增加,确保像素值在0到255之间。 Bright1直接操作原始图像的扫描线,而Bright2和Bright3创建新的QImage对象以保存修改后的结果。
摘要由CSDN通过智能技术生成