Qt图片转灰度

主要使用到计算灰度索引值的函数qGray()

    for (int i = 0; i < srcImage.width(); i++)
    {
        for (int j= 0; j < srcImage.height(); j++)
        {
            QRgb color = srcImage.pixel(i, j);
            int gray = qGray(color);
            srcImage.setPixel(i, j, qRgba(gray, gray, gray, qAlpha(color)));
        }
    }

Qt图片转灰度_第1张图片

需要完整代码请访问 QtWidgetsExamples

联系方式:


作者 郑天佐
QQ 278969898
主页 http://www.camelstudio.cn/
邮箱 [email protected]
博客 http://blog.csdn.net/zhengtianzuo06/
github https://github.com/zhengtianzuo
QQ群 199672080

捐赠

觉得分享的内容还不错, 就请作者喝杯咖啡吧~~

你可能感兴趣的:(界面开发)