Qt/C++ 改变图片亮度算法 注意是算法
2017-01-17 23:52
459 查看
QImage Bright1(QImage &image,int brightness)
{
uchar *line =image.scanLine(0);
uchar *pixel = line;
}
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 = line;
QImage * newImage = new QImage(origin.width(), origin.height(), QImage::Format_ARGB32);
for(int y=0; yheight(); ++y)
{
for(int x=0; xwidth(); ++x)
{
oldColor = QColor(image.pixel(x,y));
r = oldColor.red() + brightness;
g = oldColor.green() + brightness;
b = oldColor.blue() + brightness;
newImage->setPixel(x,y, qRgb(r,g,b));
}
}
}
QImage Bright3(QImage& source, int factor)
{
if (factor < -255 || factor > 255)
return source;
}
总体思路就是获取每一个像素点,再通过一个什么什么算法计算出该出该像素的值,再重新设置该像素点的值,差不多就是这样
powered by:小乌龟在大乌龟背上
文章来源:http://blog.csdn.net/what951006
{
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 = line;
QImage * newImage = new QImage(origin.width(), origin.height(), QImage::Format_ARGB32);
for(int y=0; yheight(); ++y)
{
for(int x=0; xwidth(); ++x)
{
oldColor = QColor(image.pixel(x,y));
r = oldColor.red() + brightness;
g = oldColor.green() + brightness;
b = oldColor.blue() + brightness;
newImage->setPixel(x,y, qRgb(r,g,b));
}
}
return *newImage;
}
QImage Bright3(QImage& source, int factor)
{
if (factor < -255 || factor > 255)
return source;
int red, green, blue; int pixels = source.width() * source.height(); unsigned int *data = (unsigned int *)source.bits(); for (int i = 0; i < pixels; ++i) { red= qRed(data[i])+ factor; red = (red < 0x00) ? 0x00 : (red > 0xff) ? 0xff : red; green= qGreen(data[i])+factor; green = (green < 0x00) ? 0x00 : (green > 0xff) ? 0xff : green; blue= qBlue(data[i])+factor; blue = (blue < 0x00) ? 0x00 : (blue > 0xff) ? 0xff : blue ; data[i] = qRgba(red, green, blue, qAlpha(data[i])); } return source;
}
总体思路就是获取每一个像素点,再通过一个什么什么算法计算出该出该像素的值,再重新设置该像素点的值,差不多就是这样
powered by:小乌龟在大乌龟背上
文章来源:http://blog.csdn.net/what951006
相关文章推荐
- Qt/C++ 改变图片亮度算法 注意是算法
- Qt 改变图片亮度算法
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- 从Symbian C++到Qt编程的注意事项(2)--描述符与Unicode In Qt
- paip.c++ qt 图片处理 检测损坏的图片
- 【c/c++ 算法/数据结构】 邻接矩阵表示图,深度,广度优先遍历 算法设计+代码+图片
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- Qt 图片随窗口改变
- 使用Qt合并图片的算法
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- C++在使用Qt中SLOT宏需要注意的一个小细节
- 模板之小试牛刀---我有点明白为什么这么多人骂c++了(终,算法改变世界)
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- Qt中设置widget背景颜色/图片的注意事项
- paip.c++ qt 图片处理 检测损坏的图片
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- OpenCV自带例子(四)改变一张图片的对比度与亮度
- Qt中设置widget背景颜色/图片的注意事项(使用样式表 setStyleSheet())
- Qt实现大图片快速缩小的算法