Example #1
0
void configDialog::setColours(QColor main, QColor peak) {
    int r,g,b,opacity;
    QString style;

    mainGraph=main;
    peakGraph=peak;

    main.getRgb(&r, &g, &b, &opacity);
    ui->mainColourPushbutton->setWindowOpacity(opacity);

    style="background-color: rgba(" + QString::number(r) + ","
            + QString::number(g) + ","
            + QString::number(b) + ","
            + QString::number(opacity)
            + "); color: rgb(0,0,0,)";
    ui->mainColourPushbutton->setStyleSheet(style);

    peak.getRgb(&r, &g, &b, &opacity);
    ui->peakColourPushbutton->setWindowOpacity(opacity);

    style="background-color: rgba(" + QString::number(r) + ","
            + QString::number(g) + ","
            + QString::number(b) + ","
            + QString::number(opacity)
            + "); color: rgb(0,0,0,)";
    ui->peakColourPushbutton->setStyleSheet(style);
}
Example #2
0
QColor SerenityHandler::colorMix(QColor bgColor, QColor fgColor, int alpha)
{
	if (alpha > 255) alpha = 255;
	if (alpha < 0) alpha = 0;

	int bred, bgrn, bblu, fred, fgrn, fblu;
	bgColor.getRgb(&bred, &bgrn, &bblu);
	fgColor.getRgb(&fred, &fgrn, &fblu);
	return QColor( fred + ((bred-fred)*alpha)/255,
			fgrn + ((bgrn-fgrn)*alpha)/255,
			fblu + ((bblu-fblu)*alpha)/255 );
}
Example #3
0
bool
FX::haveContrast(const QColor &a, const QColor &b)
{
    int ar,ag,ab,br,bg,bb;
    a.getRgb(&ar,&ag,&ab);
    b.getRgb(&br,&bg,&bb);

    int diff = (299*(ar-br) + 587*(ag-bg) + 114*(ab-bb));

    if (qAbs(diff) < 91001)
        return false;

    diff = (299*qAbs(ar - br) + 587*qAbs(ag - bg) + 114*qAbs(ab - bb)) / 300;

    return (diff > 300);
}
Example #4
0
ColorFormatDlg::ColorFormatDlg( JuffPlugin* plugin, const QColor& color, QWidget* parent) : QDialog(parent) {
	_ui.setupUi( this );
	
	_plugin = plugin;
	
	connect( _ui.buttonBox, SIGNAL(accepted()), SLOT(accept()) );
	connect( _ui.buttonBox, SIGNAL(rejected()), SLOT(reject()) );
	
	int r, g, b;
	color.getRgb( &r, &g, &b );
	
	_ui.btnHtml->setText( color.name() );
	_ui.btnHex->setText( color.name().replace("#", "0x") );
	_ui.btnHexSplitted->setText( QString().sprintf("0x%02hX, 0x%02hX, 0x%02hX", r, g, b) );
	_ui.btnSplitted->setText( QString().sprintf("%i, %i, %i", r, g, b) );
	
	_ui.buttonGroup->setId( _ui.btnHtml, 0 );
	_ui.buttonGroup->setId( _ui.btnHex, 1 );
	_ui.buttonGroup->setId( _ui.btnHexSplitted, 2 );
	_ui.buttonGroup->setId( _ui.btnSplitted, 3 );
	
//	_ui.btnHtml->setChecked( true );
	int id = PluginSettings::getInt( plugin, "format", 0 );
	QAbstractButton* btn = _ui.buttonGroup->button( id );
	if ( btn != 0 ) {
		btn->setChecked( true );
	}
	else {
		_ui.btnHtml->setChecked( true );
	}
}
Example #5
0
/**
 * Update the gradient bar colors
 */
void ColorDialog::updateBars()
{
	QColor col = color();
	int r,g,b;
	qreal h,s,v;
	col.getRgb(&r,&g,&b);
	col.getHsvF(&h,&s,&v);
	if(h<0)
		h = validhue_/360.0;

	ui_->red->setColor1(QColor(0,g,b));
	ui_->red->setColor2(QColor(255,g,b));

	ui_->green->setColor1(QColor(r,0,b));
	ui_->green->setColor2(QColor(r,255,b));

	ui_->blue->setColor1(QColor(r,g,0));
	ui_->blue->setColor2(QColor(r,g,255));

	ui_->hue->setColorSaturation(s);
	ui_->hue->setColorValue(v);

	ui_->saturation->setColor1(QColor::fromHsvF(h,0,v));
	ui_->saturation->setColor2(QColor::fromHsvF(h,1,v));

	ui_->value->setColor1(QColor::fromHsvF(h,s,0));
	ui_->value->setColor2(QColor::fromHsvF(h,s,1));

	if(showalpha_) {
		ui_->alpha->setColor1(QColor(r,g,b,0));
		ui_->alpha->setColor2(QColor(r,g,b,255));
	}
}
void ConfigurationVector::setValue(QString _key, QColor _value)
{

    QString currentValue;
    int red,green,blue;
    QString redHex, greenHex, blueHex;

    _value.getRgb(&red,&green,&blue);
    redHex.setNum(red,16);

    if (redHex.length() == 1)
    {
        redHex = "0" + redHex;
    }

    greenHex.setNum(green,16);

    if (greenHex.length() == 1)
    {
        greenHex = "0" + greenHex;
    }

    blueHex.setNum(blue,16);

    if (blueHex.length() == 1)
    {
        blueHex = "0" + blueHex;
    }

    currentValue = "C" + redHex + greenHex + blueHex;

    setValue(_key, currentValue);

}
Example #7
0
void CMYKChoose::setColor2(int h, int s, bool ende)
{
	ScColor tmp;
	if (Farbe.getColorModel() == colorModelLab)
	{
		if (isHLC)
			tmp = ScColor(MagentaSp->value(), static_cast<double>(h), static_cast<double>(s));
		else
			tmp = ScColor(CyanSp->value(), static_cast<double>(h), static_cast<double>(s));
	}
	else
	{
		QColor tm = QColor::fromHsv(qMax(qMin(359,h),0), qMax(qMin(255,255-s),0), 255-BlackComp, QColor::Hsv);
		int r, g, b;
		tm.getRgb(&r, &g, &b);
		tmp.fromQColor(tm);
		if (Farbe.getColorModel() == colorModelCMYK)
		{
			CMYKColor cmyk;
			ScColorEngine::getCMYKValues(tmp, m_doc, cmyk);
			tmp.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
		}
	}
	imageN.fill( ScColorEngine::getDisplayColor(tmp, m_doc) );
	if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
		paintAlert(alertIcon, imageN, 2, 2, false);
	NewC->setPixmap( imageN );
	Farbe = tmp;
	if (ende)
		setValues();
}
Example #8
0
void KHueSaturationSelector::drawPalette( QPixmap *pixmap )
{
    int xSize = contentsRect().width(), ySize = contentsRect().height();
    QImage image( QSize( xSize, ySize ), QImage::Format_RGB32 );
    QColor col;
    int h, s;
    uint *p;

    col.setHsv( hue(), saturation(), colorValue() );

    int _h, _s, _v, _r, _g, _b;
    col.getHsv( &_h, &_s, &_v );
    col.getRgb( &_r, &_g, &_b );

	for ( s = ySize-1; s >= 0; s-- )
	{
        p = ( uint * ) image.scanLine( ySize - s - 1 );
		for( h = 0; h < xSize; h++ )
		{
            switch ( chooserMode() ) {
            case ChooserClassic:
            default:
                col.setHsv( 359 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ), 192 );
                break;
            case ChooserHue:
                col.setHsv( _h, 255 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
                break;
            case ChooserSaturation:
                col.setHsv( 359 * h / ( xSize - 1 ), _s, 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
                break;
            case ChooserValue:
                col.setHsv( 359 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ), _v );
                break;
            case ChooserRed:
                col.setRgb( _r, 255 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
                break;
            case ChooserGreen:
                col.setRgb( 255 * h / ( xSize - 1 ), _g, 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
                break;
            case ChooserBlue:
                col.setRgb( 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ), 255 * h / ( xSize - 1 ), _b );
                break;
            }

            *p = col.rgb();
            p++;
        }
    }

    /*
    if ( pixmap->depth() <= 8 )
    {
        const QVector<QColor> standardPalette = kdeui_standardPalette();
        KImageEffect::dither( image, standardPalette.data(), standardPalette.size() );
    }
    */
    *pixmap = QPixmap::fromImage( image );
}
Example #9
0
/*
 * Update the QtHtmSublayer grid display after running the CLA.
 */
void QtFront::UpdateHtmDisplay()
{
    QGridLayout *currGrid = (QGridLayout *)smiLayerGroup->layout();
    QGridLayout *newHtmGrid = HtmDisplay->UnitGrid(objHtm); 
    HtmSublayer **sublayers = htm->GetSublayers();
    unsigned int h = sublayers[0]->GetHeight();
    unsigned int w = sublayers[0]->GetWidth();
    unsigned int d = sublayers[0]->GetDepth();
    QtUnit *colUnit = NULL;
    QList<QtCell *> qtCells;
    //QGridLayout *cellGrid = NULL;
    QColor rgb[d+1];
    int r[d+1], g[d+1], b[d+1];

    for (unsigned int i=0; i<h; i++) {
        for (unsigned int j=0; j<w; j++) {
            colUnit = (QtUnit *)newHtmGrid->itemAtPosition(i, j)->widget();
            //cellGrid = colUnit->GetCellGrid();
            rgb[0] = colUnit->getBrushColor();
            rgb[0].getRgb(&r[0], &g[0], &b[0]);
            qtCells = colUnit->findChildren<QtCell *>();
            for (unsigned int c=1; c<=d; c++) {
                rgb[c] = qtCells.at(c-1)->getBrushColor();
                rgb[c].getRgb(&r[c], &g[c], &b[c]);
            }
            colUnit =
                (QtUnit *)currGrid->itemAtPosition(i, j)->widget();
            colUnit->setBrushColor(QColor(r[0], g[0], b[0]));
            qtCells = colUnit->findChildren<QtCell *>();
            for (unsigned int c=1; c<=d; c++)
                qtCells.at(c-1)->setBrushColor(
                    QColor(r[c], g[c], b[c])
                );
        }
    }

    QGridLayout *currPoolingGrid = (QGridLayout *)poolGroup->layout();
    QGridLayout *newPoolingGrid = HtmDisplay->PoolUnitGrid(objHtm);
    PoolingLayer *p = htm->GetPoolingLayer();
    h = p->GetHeight();
    w = p->GetWidth();
    QColor rgbPool;
    int rP, gP, bP;

    for (unsigned int i=0; i<h; i++) {
        for (unsigned int j=0; j<w; j++) {
            colUnit =
                (QtUnit *)newPoolingGrid->itemAtPosition(i, j)->widget();
            rgbPool = colUnit->getBrushColor();
            rgbPool.getRgb(&rP, &gP, &bP);
            colUnit =
                (QtUnit *)currPoolingGrid->itemAtPosition(i, j)->widget();
            colUnit->setBrushColor(
                QColor(rP, gP, bP));
        }
    }
}
Example #10
0
QString BookmarksProtocol::htmlColor(const QColor &col)
{
  int r, g, b;
  col.getRgb(&r, &g, &b);
  QString num;

  num.sprintf("#%02X%02X%02X", r, g, b);
  return num;
}
Example #11
0
void
FX::setColor(XRenderColor &xc, QColor qc)
{
    uint a, r, g, b;
    qc.getRgb((int*)&r, (int*)&g, (int*)&b, (int*)&a);
    a = xc.alpha = (a | a << 8);
    xc.red   = (r | r << 8) * a / 0x10000;
    xc.green = (g | g << 8) * a / 0x10000;
    xc.blue  = (b | b << 8) * a / 0x10000;
}
Example #12
0
int
FX::contrastOf(const QColor &a, const QColor &b)
{
    int ar,ag,ab,br,bg,bb;
    a.getRgb(&ar,&ag,&ab);
    b.getRgb(&br,&bg,&bb);

    int diff = 299*(ar-br) + 587*(ag-bg) + 114*(ab-bb);
    diff = (diff < 0) ? -diff : 90*diff/100;
    int perc = diff / 2550;

    diff = qMax(ar,br) + qMax(ag,bg) + qMax(ab,bb)
        - (qMin(ar,br) + qMin(ag,bg) + qMin(ab,bb));

    perc += diff/765;
    perc /= 2;

    return perc;
}
Example #13
0
void msl::colorChanged(const QColor & color)
{
	//Get RGB values of the current color
	int r, g, b, h, s, v;

	color.getRgb(&r, &g, &b);
	color.getHsv(&h, &s, &v);

	updateLEDs();
}
Example #14
0
// Open color selector, and take color if it is valid
void ColorSelector::qtSelectorPressed()
{
  QColor retColor = QColorDialog::getColor(QColor(mCurrentRGB[0],
                                                  mCurrentRGB[1],
                                                  mCurrentRGB[2]), this);
  if (!retColor.isValid())
    return;
  retColor.getRgb(&mCurrentRGB[0], &mCurrentRGB[1], &mCurrentRGB[2]);
  imposeColor(true, true);
}
Example #15
0
void KColorDialog::KColorDialogPrivate::setHtmlEdit(const QColor &col)
{
    if (bEditHtml) return;
    int r, g, b;
    col.getRgb(&r, &g, &b);
    QString num;

    num.sprintf("#%02X%02X%02X", r, g, b);
    htmlName->setText(num);
}
Example #16
0
void KColorDialog::KColorDialogPrivate::setRgbEdit(const QColor &col)
{
    if (bEditRgb) return;
    int r, g, b;
    col.getRgb(&r, &g, &b);

    redit->setValue(r);
    gedit->setValue(g);
    bedit->setValue(b);
}
Example #17
0
QString coloredText(const QString &text, QColor color){
    int r, b, g, a;
    color.getRgb(&r,&g,&b, &a);
    qDebug() << r << g << b;
    QString c = "rgb(" + QString::number(r) + "," + QString::number(g) + "," + QString::number(b) + ")";
    qDebug() << c;
    QString res = "<pre style=\" font-weight: bold; color:" + c + ";\">" + text + "  </pre>";

    return res;
}
Example #18
0
QColor LCGraphicsItem::getScreenColor(const QColor& color) const {
    int r, g, b, a;
    color.getRgb(&r, &g, &b, &a);

    // FIXME: If the background of the screen is dark, or light swap or not swap collors accordingly for dark and light pens
    if (r < 0x10 && g < 0x10 && b < 0x10) {
        return QColor(0xff - r, 0xff - g, 0xff - b);
    }

    return color;
}
Example #19
0
inline QRgb color_to_pixel( const QColor & color )
{
    int r, g, b, a;
    color.getRgb( &r, &g, &b, &a );
    qreal k = a / 255.f;
    r *= k;
    g *= k;
    b *= k;
    QRgb pixel = (a << 24) | (r << 16) | (g << 8) | b;
    return pixel;
}
Example #20
0
void MainWindow::on_toolButtonColor_clicked()
{
    const QColor color = QColorDialog::getColor();
    if (color.isValid())
    {
        int red, green, blue, alpha;
        color.getRgb(&red, &green, &blue, &alpha);
        ui->lineEditColor->setText(color.name());
        this->setColor(red, green, blue);
    }
}
Example #21
0
void YZPrinter::convertColor(const QColor& c, double &r, double &g, double &b)
{
    int r0, g0, b0;

    c.getRgb(&r0, &g0, &b0);
    r = r0;
    r /= 255;
    g = g0;
    g /= 255;
    b = b0;
    b /= 255;
}
void QmitkColorPropertyEditor::onColorSelected(QColor c)
{
  if (m_ColorProperty)
  {
    int r,g,b;
    c.getRgb( &r, &g, &b );
    const_cast<mitk::ColorProperty*>(m_ColorProperty)->SetColor( r / 255.0, g / 255.0, b / 255.0 );
    const_cast<mitk::ColorProperty*>(m_ColorProperty)->Modified();

    mitk::RenderingManager::GetInstance()->RequestUpdateAll();
  }
}
Example #23
0
void PaletteGrid::dropEvent(QDropEvent * event)
{
    VoxelFile * voxel = window->get_voxel();
    if (!voxel)
        return;
    int r, g, b;
    QColor color = event->mimeData()->colorData().value<QColor>();
    color.getRgb(&r, &g, &b);
    int i = get_index(event->pos());
    global_palette[i] = RGBColor(r, g, b);
    event->acceptProposedAction();
    update();
    window->model_changed();
}
Example #24
0
void mW::on_btnSelectBgColor_clicked()
{
  int r,g,b;
  QColor myColor;
  myColor.setRgba(QColorDialog::getRgba(0x00));
  myColor.getRgb(&r,&g,&b);
  
  QString bgColorStyleSheet;
  char sh[64];
  sprintf(sh, "background-color: rgb(%i, %i, %i);", r,g,b);
  bgColorStyleSheet=sh;
  btnSelectBgColor->setStyleSheet(bgColorStyleSheet);
  sprintf(sh, "%02x%02x%02x",r,g,b);
  osggBackgroundColor=sh;
}
Example #25
0
// Process a colorization and update resultant HSL & RGB values
void QgsHueSaturationFilter::processColorization( int &r, int &g, int &b, int &h, int &s, int &l )
{
  QColor myColor;

  // Overwrite hue and saturation with values from colorize color
  h = mColorizeH;
  s = mColorizeS;


  QColor colorizedColor = QColor::fromHsl( h, s, l );

  if ( mColorizeStrength == 100 )
  {
    // Full strength
    myColor = colorizedColor;

    // RGB may have changed, update them
    myColor.getRgb( &r, &g, &b );
  }
  else
  {
    // Get rgb for colorized color
    int colorizedR, colorizedG, colorizedB;
    colorizedColor.getRgb( &colorizedR, &colorizedG, &colorizedB );

    // Now, linearly scale by colorize strength
    double p = ( double ) mColorizeStrength / 100.;
    r = p * colorizedR + ( 1 - p ) * r;
    g = p * colorizedG + ( 1 - p ) * g;
    b = p * colorizedB + ( 1 - p ) * b;

    // RGB changed, so update HSL values
    myColor = QColor::fromRgb( r, g, b );
    myColor.getHsl( &h, &s, &l );
  }
}
Example #26
0
void ScColor::fromQColor(QColor color)
{
	if (color.spec() == QColor::Cmyk)
	{
		int c, m, y, k;
		color.getCmyk(&c, &m, &y, &k);
		setColor(c, m, y, k);
	}
	else
	{
		int r, g, b;
		color.getRgb(&r, &g, &b);
		setColorRGB(r, g, b);
	}
}
Example #27
0
/*Gray scale colors have roughly the same r,g, and b values*/
bool ColorListEditor::notGreyScale(QColor col)
{
	int red, green, blue;
	col.getRgb(&red, &green, &blue);
	float average = (red + green + blue) / 3.0;
	int min = (int)(average * .8);
	int max = (int)(average * 1.2);
	if( red > max || red < min )
		return true;
	if( green > max || green < min )
		return true;		
	if( blue > max || blue < min )
		return true;
		
	return false;
}
Example #28
0
void CSchemas::on_tableView_pressed ( const QModelIndex & index )
{
	if ( index.column() < 2 )
	{
		m_activeIndex = index;

		int iRed, iGreen, iBlue;
		QColor color = m_model->data ( m_activeIndex, Qt::BackgroundColorRole ).value<QColor>();

		color.getRgb ( &iRed, &iGreen, &iBlue );

		slRed->setValue ( iRed );
		slGreen->setValue ( iGreen );
		slBlue->setValue ( iBlue );
	}
}
Example #29
0
void MainWindow::on_lineEditColor_editingFinished()
{
    QColor color;
    color.setNamedColor(ui->lineEditColor->text());
    if (color.isValid())
    {
        int red, green, blue, alpha;
        color.getRgb(&red, &green, &blue, &alpha);

        this->setColor(red, green, blue);
    }
    else
    {
        QColor oldColor = ui->SFMLWidget->getColor();
        ui->lineEditColor->setText(oldColor.name());
    }
}
Example #30
0
void
FX::desaturate(QImage &img, const QColor &c)
{
    int r,g,b; c.getRgb(&r, &g, &b);
    uchar reds[256], greens[256], blues[256];

    for (int i=0; i<128; ++i)
    {
        reds[i]   = uchar((r * (i<<1)) >> 8);
        greens[i] = uchar((g * (i<<1)) >> 8);
        blues[i]  = uchar((b * (i<<1)) >> 8);
    }
    for (int i=0; i<128; ++i)
    {
        reds[i+128]   = uchar(qMin(r   + (i << 1), 255));
        greens[i+128] = uchar(qMin(g + (i << 1), 255));
        blues[i+128]  = uchar(qMin(b + (i << 1), 255));
    }

    int intensity = qt_intensity(r, g, b);
    const int f = 191;

    if ((r - f > g && r - f > b) || (g - f > r && g - f > b) || (b - f > r && b - f > g))
        intensity = qMin(255, intensity + 91);
    else if (intensity <= 128)
        intensity -= 51;

    for (int y = 0; y < img.height(); ++y)
    {
        QRgb *scanLine = (QRgb*)img.scanLine(y);
        for (int x = 0; x < img.width(); ++x)
        {
            QRgb pixel = *scanLine;
            uint ci = uint(qGray(pixel)/3 + (130 - intensity / 3));
            *scanLine = qRgba(reds[ci], greens[ci], blues[ci], qAlpha(pixel));
            ++scanLine;
        }
    }
}