本文整理汇总了C++中QColor::setRed方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setRed方法的具体用法?C++ QColor::setRed怎么用?C++ QColor::setRed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setRed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adArAv
void AdaptAver::adArAv(int curx, int cury, int powerX, int powerY)
{ //Adaptive Arithmetic Average
//qDebug() << "adarav";
QList<int> proxArrayR; //массивы пикселей окрестности точки
QList<int> proxArrayG; //для трёх цветов (red, green, blue)
QList<int> proxArrayB;
for (int y = cury - powerY; y <= cury+ powerY; y++)
for (int x = curx - powerX; x <= curx+ powerX; x++)
{//проверяем окрестные пиксели
if ((0 <= x && x <= image.width()-1) && (0 <= y && y <= image.height()-1))
{ //записываем значения
QColor pixel = image.pixel(x, y);
proxArrayR.append(pixel.red());
proxArrayG.append(pixel.green());
proxArrayB.append(pixel.blue());
}
else { //если мы за пределами картинки - записываем чёрный цвет
proxArrayR.append(0);
proxArrayG.append(0);
proxArrayB.append(0);
}
}
QColor pixel = image.pixel(curx, cury);//(QColor(0, 0, 0, 255)); //makin a pixel
int aveRed = listAverage(proxArrayR); //устанавливаем значение его цветов равным
int aveGreen = listAverage(proxArrayG);//среднему арифметическому массива ближайших пикселей
int aveBlue = listAverage(proxArrayB);
double dispRed = listDisp(proxArrayR, aveRed); //считаем дисперсии значений этих массивов
double dispGreen = listDisp(proxArrayG, aveGreen);
double dispBlue = listDisp(proxArrayB, aveBlue);
if (dispNoise > dispRed) //если значение дисперсии шума выше, чем дисперсия массива окрестности
pixel.setRed(aveRed); //фильтр работает как фильтр арифметического среднего
if (dispNoise <= dispRed) //иначе значение задается по формуле z' = z - (Dшум/Dz)*(z - u), u - локальное среднее яркости пикселей
pixel.setRed(pixel.red()- (dispNoise/dispRed)*(pixel.red()-aveRed));
if (dispNoise > dispGreen)
pixel.setGreen(aveGreen);
if (dispNoise <= dispGreen)
pixel.setGreen(pixel.green()- (dispNoise/dispGreen)*(pixel.green()-aveGreen));
if (dispNoise > dispBlue)
pixel.setBlue(aveBlue);
if (dispNoise <= dispBlue)
pixel.setBlue(pixel.blue()- (dispNoise/dispBlue)*(pixel.blue()-aveBlue));
if ((0 <= curx && curx <= image.width()-1) && (0 <= cury && cury <= image.height()-1))
result.setPixel(curx, cury, pixel.rgb()); //записываем значение в результат
}
示例2: SetColor
void Widget::SetColor(double cosDifuse,double cosSpecular)
{
// qDebug() << cosDifuse;
if (cosDifuse < 0) {cosDifuse = 0;}
if (cosSpecular < 0) {cosSpecular = 0 ;}
double red,green,blue;
red = color_anbient.red()/255.0+
cosDifuse*color_diffuse.red()/255.0+
// pow(cosSpecular*color_specular.red()/255.0,intense);
cosSpecular*color_specular.red()/255.0;
color.setRed(max(0,min(red*255,255)));
green = color_anbient.green()/255.0+
cosDifuse*color_diffuse.green()/255.0+
// pow(cosSpecular*color_specular.green()/255.0,intense);
cosSpecular*color_specular.green()/255.0;
color.setGreen(max(0,min(green*255,255)));
blue = color_anbient.blue()/255.0+
cosDifuse*color_diffuse.blue()/255.0+
// pow(cosSpecular*color_specular.blue()/255.0,intense);
cosSpecular*color_specular.blue()/255.0;
color.setBlue(max(0,min(blue*255,255)));
}
示例3: clamp
static QColor red2yellow2green(qreal x)
{
QColor color;
x = clamp(x, 0.0, 1.0);
if (x <= 0.5) {
x *= 2;
color.setRed(255);
color.setGreen(255 * x);
}
else {
x = 2 * x - 1;
color.setRed(255 - 255 * x);
color.setGreen(255);
}
return color;
}
示例4: determineColor
QColor Viewport::determineColor(const QColor &basecolor,
float weight, float totalweight,
bool highlighted, bool single)
{
QColor color = basecolor;
qreal alpha;
/* TODO: this is far from optimal yet. challenge is to give a good
view where important information is not lost, yet not clutter
the view with too much low-weight information */
/* logarithm is used to prevent single data points to get lost.
this should be configurable. */
alpha = useralpha;
if (drawLog->isChecked())
alpha *= (0.01 + 0.99*(std::log(weight+1) / std::log(totalweight)));
else
alpha *= (0.01 + 0.99*(weight / totalweight));
color.setAlphaF(std::min(alpha, 1.)); // cap at 1
if (highlighted) {
if (basecolor == Qt::white) {
color = Qt::yellow;
} else {
color.setGreen(std::min(color.green() + 195, 255));
color.setRed(std::min(color.red() + 195, 255));
color.setBlue(color.blue()/2);
}
color.setAlphaF(1.);
}
// recolor singleLabel (and make 100% opaque)
if (single) {
color.setRgbF(1., 1., 0., 1.);
}
return color;
}
示例5: apply
void RedEyeReductionImageOperation::apply(QImage* img, const QRectF& rectF)
{
const QRect rect = PaintUtils::containingRect(rectF);
const qreal radius = rectF.width() / 2;
const qreal centerX = rectF.x() + radius;
const qreal centerY = rectF.y() + radius;
const Ramp radiusRamp(qMin(double(radius * 0.7), double(radius - 1)), radius, 1., 0.);
uchar* line = img->scanLine(rect.top()) + rect.left() * 4;
for (int y = rect.top(); y < rect.bottom(); ++y, line += img->bytesPerLine()) {
QRgb* ptr = (QRgb*)line;
for (int x = rect.left(); x < rect.right(); ++x, ++ptr) {
const qreal currentRadius = sqrt(pow(y - centerY, 2) + pow(x - centerX, 2));
qreal alpha = radiusRamp(currentRadius);
if (qFuzzyCompare(alpha, 0)) {
continue;
}
const QColor src(*ptr);
alpha *= computeRedEyeAlpha(src);
int r = src.red();
int g = src.green();
int b = src.blue();
QColor dst;
// Replace red with green, and blend according to alpha
dst.setRed(int((1 - alpha) * r + alpha * g));
dst.setGreen(int((1 - alpha) * g + alpha * g));
dst.setBlue(int((1 - alpha) * b + alpha * b));
*ptr = dst.rgba();
}
}
}
示例6: alterColor
void QgsColorWidget::alterColor( QColor& color, const QgsColorWidget::ColorComponent component, const int newValue ) const
{
int h, s, v, a;
color.getHsv( &h, &s, &v, &a );
//clip value to sensible range
int clippedValue = qMin( qMax( 0, newValue ), componentRange( component ) );
switch ( component )
{
case QgsColorWidget::Red:
color.setRed( clippedValue );
return;
case QgsColorWidget::Green:
color.setGreen( clippedValue );
return;
case QgsColorWidget::Blue:
color.setBlue( clippedValue );
return;
case QgsColorWidget::Hue:
color.setHsv( clippedValue, s, v, a );
return;
case QgsColorWidget::Saturation:
color.setHsv( h, clippedValue, v, a );
return;
case QgsColorWidget::Value:
color.setHsv( h, s, clippedValue, a );
return;
case QgsColorWidget::Alpha:
color.setAlpha( clippedValue );
return;
default:
return;
}
}
示例7: initialize
void Renderer::initialize(xqtgl::window* surface)
{
m_backgroundColor = QColor::fromRgbF(0.1f, 0.1f, 0.2f, 1.0f);
m_backgroundColor.setRed(qrand() % 64);
m_backgroundColor.setGreen(qrand() % 128);
m_backgroundColor.setBlue(qrand() % 256);
}
示例8: if
void MIPS32SyntaxHighlighter::setBackgroundColor(QColor const &color){
MIPS32SyntaxHighlighter::backgroundColor = color;
int red = color.red();
int blue = color.blue();
int green = color.green();
int offset = (int)(DEFAULT_COLOR_BACKGROUND_HIGHLIGHT_RATIO * 256.0);
if(offset < 0){
if(red+offset < 0){red-=offset;}else{red+=offset;}
if(green+offset < 0){green-=offset;}else{green+=offset;}
if(blue+offset < 0){blue-=offset;}else{blue+=offset;}
}else if(offset > 0){
if(red+offset > 255){red-=offset;}else{red+=offset;}
if(green+offset > 255){green-=offset;}else{green+=offset;}
if(blue+offset > 255){blue-=offset;}else{blue+=offset;}
}else{
//don't change color
}
QColor tmpColor;
tmpColor.setRed(red);
tmpColor.setBlue(blue);
tmpColor.setGreen(green);
MIPS32SyntaxHighlighter::backgroundHighlightColor = tmpColor;
}
示例9: mouseReleaseEvent
void EyedropperTool::mouseReleaseEvent(QMouseEvent *event)
{
Layer* layer = mEditor->layers()->currentLayer();
if (layer == NULL) { return; }
if (event->button() == Qt::LeftButton)
{
if (layer->type() == Layer::BITMAP)
{
BitmapImage* targetImage = ((LayerBitmap *)layer)->getLastBitmapImageAtFrame( mEditor->currentFrame(), 0);
//QColor pickedColour = targetImage->pixel(getLastPoint().x(), getLastPoint().y());
QColor pickedColour;
pickedColour.setRgba( targetImage->pixel( getLastPoint().x(), getLastPoint().y() ) );
int transp = 255 - pickedColour.alpha();
pickedColour.setRed( pickedColour.red() + transp );
pickedColour.setGreen( pickedColour.green() + transp );
pickedColour.setBlue( pickedColour.blue() + transp );
if (pickedColour.alpha() != 0)
{
mEditor->color()->setColor(pickedColour);
}
}
else if (layer->type() == Layer::VECTOR)
{
VectorImage *vectorImage = ((LayerVector *)layer)->getLastVectorImageAtFrame(mEditor->currentFrame(), 0);
int colourNumber = vectorImage->getColourNumber(getLastPoint());
if (colourNumber != -1)
{
mEditor->color()->setColorNumber(colourNumber);
}
}
}
}
示例10: GetColor
QColor ColorMappingGenerator::GetColor(ColorMappingType color_type, float current_value, float min_value, float max_value){
float value = current_value;
if ( value < min_value ) value = min_value;
if ( value > max_value ) value = max_value;
if ( value < color_index_vec_[color_type][0].value_index ) value = color_index_vec_[color_type][0].value_index;
if ( value > color_index_vec_[color_type][color_index_vec_[color_type].size() - 1].value_index ) value = color_index_vec_[color_type][color_index_vec_[color_type].size() - 1].value_index;
int current_index = 0;
while ( current_index < color_index_vec_[color_type].size() && value > color_index_vec_[color_type][current_index].value_index ) current_index++;
if ( current_index == 0 )
return color_index_vec_[color_type][0].color;
else {
QColor color;
if ( is_linear_[color_type] ){
float scale = (color_index_vec_[color_type][current_index].value_index - value) / (color_index_vec_[color_type][current_index].value_index - color_index_vec_[color_type][current_index - 1].value_index);
color.setRed(scale * color_index_vec_[color_type][current_index - 1].color.red() + (1.0 - scale) * color_index_vec_[color_type][current_index].color.red());
color.setGreen(scale * color_index_vec_[color_type][current_index - 1].color.green() + (1.0 - scale) * color_index_vec_[color_type][current_index].color.green());
color.setBlue(scale * color_index_vec_[color_type][current_index - 1].color.blue() + (1.0 - scale) * color_index_vec_[color_type][current_index].color.blue());
} else {
color = color_index_vec_[color_type][current_index - 1].color;
}
return color;
}
}
示例11: paint
//render the square on the screen
void Square::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
QColor color;
if(selected)
{
//if the user clicked it, draw it purple
color.setBlue(100); color.setRed(100); color.setGreen(0);
}
else
{
//otherwise draw it white
color.setBlue(255); color.setRed(255); color.setGreen(255);
}
painter->setBrush(color);
painter->drawRect(xcoor1,ycoor1,xcoor2-xcoor1,ycoor2-ycoor1);
}
示例12: QColor
QColor KDReports::XmlHelper::readBackground( const QDomElement& element )
{
QColor ret;
if ( element.hasAttribute( QLatin1String( "background" ) ) ) {
const QString name = element.attribute( QLatin1String( "background" ) );
ret = QColor( name );
} else if( element.hasAttribute( QLatin1String( "bgred" ) ) &&
element.hasAttribute( QLatin1String( "bggreen" ) ) &&
element.hasAttribute( QLatin1String( "bgblue" ) ) ) {
int red = 0, green = 0, blue = 0;
bool ok = true;
red = element.attribute( QLatin1String( "bgred" ) ).toInt( &ok );
if( ok ) {
green = element.attribute( QLatin1String( "bggreen" ) ).toInt( &ok );
if( ok ) {
blue = element.attribute( QLatin1String( "bgblue" ) ).toInt( &ok );
if( ok ) {
ret.setRed( red );
ret.setGreen( green );
ret.setBlue( blue );
}
}
}
}
return ret;
}
示例13: mergeColors
QColor Style::mergeColors(const QColor &colorA, const QColor &colorB, int factor) const
{
QColor tmp = colorA;
tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
return tmp;
}
示例14: readColor
QColor readColor(QDomElement e)
{
QColor c;
c.setRed(e.attribute("r").toInt());
c.setGreen(e.attribute("g").toInt());
c.setBlue(e.attribute("b").toInt());
return c;
}
示例15: dampColors
static void dampColors(QColor &col)
{
//Reduce the colors that are less visible to the eye, because they are closer to black when it comes to contrast
//The most significant color to the eye is green. Then comes red, and then blue, with blue _much_ less significant.
col.setBlue(0);
col.setRed(col.red() / 2);
}