本文介绍了改变QImage / QPixmap的色调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这更像是一个图形操作问题,但我想在Qt(c ++)中完成。如果我有一张图片 - 让我们只是在透明背景上说一个浅灰色的圆圈,Qt中是否有内置的功能来将色调/饱和度转换为彩色?

I suppose this is more of a graphics manipulation question in general, but I'd like to accomplish this in Qt (c++). If I have an image - let's just say a circle on a transparent background - of a light gray color, is there any built-in functionality in Qt to shift the hue / saturation to color it?

我想我可以逐像素地去修改rgb,在数学上增加x到r,g和b,以得到想要的颜色,但必须有一个比修改每一个像素更好的方法。

I suppose I could go pixel by pixel, and modifying the rgb mathematically - add x to r, g, and b, to get a desired color, but there must be a better way than modifying every single pixel.

Qt Docs没有任何东西可以用于图像处理,只是改变alpha和颜色。我应该看看一个开源库吗(最终结果可能是一个独立销售的软件)?如果是这样,有什么建议吗?或者是否有隐藏在Qt文档中的秘密功能,可以在不需要外部库/疯狂算法的情况下完成?

Nothing in the Qt Docs goes this far into image manipulation, just altering alpha and colors. Should I look into an open source library (the end result will likely be an independently sold software)? If so, are there any recommendations? Or is there a secret function hidden in the Qt docs that can accomplish without the need of outside libraries / crazy algorithms?

推荐答案

一种可能的行动方式:

A possible course of action:



  1. 执行 QImage
    QImage :: convertToFormat(QImage :: Format_Indexed8)
    使用颜色表获取带索引的
    图像
  2. 使用 QRgb
    获取颜色表格值QImage :: color(int i)const

  3. 使用 QColor
    (QRgb颜色)
    和其他QColor方法操作颜色
  4. li>
  5. 将颜色
    表改为 void QImage :: setColor(int index,QRgb colorValue)

  1. Load your image as a QImage
  2. Do a QImageQImage::convertToFormat(QImage::Format_Indexed8) to get a indexedimage with a color table
  3. Get color table values with QRgbQImage::color ( int i ) const
  4. Manipulate the colors with QColor( QRgb color ) and the other QColor methods
  5. Alter the colortable with void QImage::setColor ( int index, QRgb colorValue )

这篇关于改变QImage / QPixmap的色调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 14:40