QuillImage LoadFilter::renderAlpha(const QuillImage &image,
                                   const QColor &backgroundColor)
{
    QuillImage target(image, QImage(image.size(), QImage::Format_RGB32));
    target.fill(backgroundColor.rgb());
    QPainter painter(&target);
    painter.drawImage(QPoint(0, 0), image);
    return target;
}
Beispiel #2
0
void Exercise123::diffusePixel(QImage &image, int x, int y, const float &weight, const float &error) {
    if (!inBounds(image, x, y)) {
        return;
    }

    QColor pixel = getPixel(image, x, y);
    QColor diffusedPixel = getDiffusedColor(pixel, weight, error);
    image.setPixel(x, y, diffusedPixel.rgb());
}
void EditorTablePropertiesForm::setColorForButtonBackgroundColor(QColor iColor)
{
  // Квадратик на кнопке выбора цвета кода
  QPixmap pix(16, 16);
  pix.fill(iColor.rgb());
  buttonBackgroundColor.setIcon(pix);

  backgroundColor=iColor;
}
Beispiel #4
0
void Canvas::paint(const QPoint center, const int radius,const QColor color,QImage& efffectiveImage){
    for(int x = center.x()-radius; x < center.x()+radius; x++){
        for(int y = center.y()-radius; y < center.y()+radius; y++){
            if(Util::calcL2Distance(center, QPoint(x,y)) < radius){
                efffectiveImage.setPixel(x, y,color.rgb());
            }
        }
    }
}
Beispiel #5
0
void ColorView::setValue(const QColor &col)
{
    if (col.rgb() == value_.rgb()) {
        return;
    }
    value_ = col;
    update();
    emit valueChanged(col);
}
Beispiel #6
0
void KbLight::color(const QColor& newColor){
    QRgb newRgb = newColor.rgb();
    QMutableHashIterator<QString, QRgb> i(_colorMap);
    while(i.hasNext()){
        i.next();
        i.value() = newRgb;
    }
    _needsSave = true;
}
Beispiel #7
0
void MainWindow::update(){
    // we draw by using a QImage - turn it into a Pixmap, then put it on a label
    QImage img(200, 200, QImage::Format_RGB32);
    bool display;
    /* Our color wheel has a radius of 100.  Loop through the rectangle
      looking for pixels within that radius. For good pixels we calculate
      the H value based on the angle from the origin.  The S value is
      set according to the distance / radius, and the V is fixed (but
      settable by a slider).
     */
    for (int i = 0; i < 200; i++)
    {
        for (int j = 0; j < 200; j++)
        {
            float dist = sqrt((i - 100) * (i - 100) + (j - 100) * (j - 100));
            if (dist < 100.0)
            {
                display = true;
                float s = dist / 100.0f;
                float h = atan2(i - 100, j - 100) / (2.0f * 3.14156);
                if (h < 0)
                {
                    h = 1.0f + h;
                }
                // Since H is an angle the math is modulo.
                if (hMax > hMin)
                {
                    if (hMin > h || hMax < h)
                    {
                        display = false;
                    }
                } else if (hMin > h && hMax < h )
                {
                    display = false;
                }
                if (s < sMin || s > sMax)
                {
                    display = false;
                }
                QColor c;
                if (display)
                {
                    c.setHsvF(h, s, zValue);
                } else{
                    c.setHsvF(0.0, 0.0, 1.0f);
                }
                img.setPixel(i, j, c.rgb());
            }
        }
    }
    QPixmap pix;
    pix.convertFromImage(img);
    ui->colwheel->setPixmap(pix);
    ui->colwheel->repaint();

}
QColor RenderReplaced::selectionColor(QPainter *p) const
{
    QColor color = RenderBox::selectionColor(p);
         
    // Force a 60% alpha so that no user-specified selection color can obscure selected images.
    if (qAlpha(color.rgb()) > 153)
        color = QColor(qRgba(color.red(), color.green(), color.blue(), 153));

    return color;
}
RGBA Qwt3D::Qt2GL(QColor col)
{
	QRgb qrgb = col.rgb();
	RGBA rgba;
	rgba.r = qRed(qrgb) / 255.0;
	rgba.g = qGreen(qrgb) / 255.0;
	rgba.b = qBlue(qrgb) / 255.0;
	rgba.a = qAlpha(qrgb) / 255.0;
	return rgba;	
}
Beispiel #10
0
void MixerDetails::trackColorChanged(QColor col)
      {
      if (trackColorLabel->color() != col) {
            trackColorLabel->blockSignals(true);
            trackColorLabel->setColor(col);
            trackColorLabel->blockSignals(false);
            }

      _mti->setColor(col.rgb());
      }
QColor macGetColor( const QColor& initial, QWidget *parent, const char *name )
{
    bool ok;
    QRgb rgb = macGetRgba( initial.rgb(), &ok, parent, name );

    QColor ret;
    if(ok)
	ret = QColor(rgb);
    return ret;
}
Beispiel #12
0
void BBTCOView::setColor( QColor new_color )
{
	if( new_color.rgb() != m_bbTCO->color() )
	{
		m_bbTCO->setColor( new_color );
		m_bbTCO->m_useStyleColor = false;
		Engine::getSong()->setModified();
		update();
	}
	BBTrack::setLastTCOColor( new_color );
}
QString QTextFormat::getKey( const QFont &fn, const QColor &col, bool misspelled, VerticalAlignment a )
{
    QString k = fn.key();
    k += '/';
    k += QString::number( (uint)col.rgb() );
    k += '/';
    k += QString::number( (int)misspelled );
    k += '/';
    k += QString::number( (int)a );
    return k;
}
Beispiel #14
0
 static void FillAndFrameBlack(QImage* image, const QColor& color, int size)
 {
     image->fill(color.rgb());
     for (int i = 0; i < size; i++)
     {
         image->setPixel(0, i, 0);
         image->setPixel(size - 1, i, 0);
         image->setPixel(i, 0, 0);
         image->setPixel(i, size - 1, 0);
     }
 }
Beispiel #15
0
/**
 * @brief Canvas::bucket
 * @brief 颜料桶工具的绘制函数,用特定的颜色填充整个图像区域
 * @param color 表示所绘制的颜色
 * @return 没有返回值
 */
void Canvas::bucket(const QColor color){
    QImage* image = &(this->layerManager->getDisplayLayerItem()->image);

    for(int x = 0; x < image->width(); x++){
        for(int y = 0; y < image->height(); y++){
            image->setPixel(x, y,color.rgb());
        }
    }

    this->update();
}
void GridClassifier::populateHistogramBins (const QImage &image,
                                            const Transformation &transformation,
                                            double xMin,
                                            double xMax,
                                            double yMin,
                                            double yMax)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GridClassifier::populateHistogramBins";

  ColorFilter filter;
  QRgb rgbBackground = filter.marginColor (&image);

  for (int x = 0; x < image.width(); x++) {
    for (int y = 0; y < image.height(); y++) {

      QColor pixel = image.pixel (x, y);

      // Skip pixels with background color
      if (!filter.colorCompare (rgbBackground,
                                pixel.rgb ())) {

        // Add this pixel to histograms
        QPointF posGraph;
        transformation.transformScreenToRawGraph (QPointF (x, y), posGraph);

        if (transformation.modelCoords().coordsType() == COORDS_TYPE_POLAR) {

          // If out of the 0 to period range, the theta value must shifted by the period to get into that range
          while (posGraph.x() < xMin) {
            posGraph.setX (posGraph.x() + transformation.modelCoords().thetaPeriod());
          }
          while (posGraph.x() > xMax) {
            posGraph.setX (posGraph.x() - transformation.modelCoords().thetaPeriod());
          }
        }

        int binX = binFromCoordinate (posGraph.x(), xMin, xMax);
        int binY = binFromCoordinate (posGraph.y(), yMin, yMax);

        ENGAUGE_ASSERT (0 <= binX);
        ENGAUGE_ASSERT (0 <= binY);
        ENGAUGE_ASSERT (binX < m_numHistogramBins);
        ENGAUGE_ASSERT (binY < m_numHistogramBins);

        // Roundoff error in log scaling may let bin go just outside legal range
        binX = qMin (binX, m_numHistogramBins - 1);
        binY = qMin (binY, m_numHistogramBins - 1);

        ++m_binsX [binX];
        ++m_binsY [binY];
      }
    }
  }
}
Beispiel #17
0
void ARenderPrivate::drawTime(QPainter *painter, QRect rect)
{
	if (time <= 0){
		return;
	}
	rect = QRect(0, rect.height() - 2, rect.width()*time, 2);
	QLinearGradient gradient;
	gradient.setStart(rect.center().x(), rect.top());
	gradient.setFinalStop(rect.center().x(), rect.bottom());
	QColor outline = qApp->palette().background().color().darker(140);
	QColor highlight = qApp->palette().color(QPalette::Highlight);
	QColor highlightedoutline = highlight.darker(140);
	if (qGray(outline.rgb()) > qGray(highlightedoutline.rgb())){
		outline = highlightedoutline;
	}
	painter->setPen(QPen(outline));
	gradient.setColorAt(0, highlight);
	gradient.setColorAt(1, highlight.lighter(130));
	painter->setBrush(gradient);
	painter->drawRect(rect);
}
const QImage& ImageTransformer::
Sample(unsigned int times)
{
    int width = _DataHandled.width();
    int height = _DataHandled.height();
    int depth = _DataHandled.depth();

    if(depth == 32)
    {
        int step = times;

        int num;
        int red,blue,green;
        QColor pixTmp;

        for(int i=0;i<width;i += step)
        {
            for(int j=0;j<height;j += step)
            {
                int i_t,j_t;
                /*统计像素点各通道值之和*/
                num = red = green = blue = 0;
                for(i_t = i; i_t < step + i && i_t < width; i_t += 1)
                {
                    for(j_t = j; j_t < step + j && j_t < height;j_t += 1)
                    {
                        pixTmp = _DataHandled.pixel(i_t,j_t);
                        red += pixTmp.red();
                        green += pixTmp.green();
                        blue += pixTmp.blue();
                        num++;
                    }
                }

                /*设置新像素点颜色*/
                red /= num;
                green /= num;
                blue /= num;
                pixTmp.setRgb(red,green,blue);

                /*替换原像素点*/
                for(int x=i;x<i_t;++x)
                {
                    for(int y=j;y<j_t;++y)
                    {
                        _DataHandled.setPixel(x,y,pixTmp.rgb());
                    }
                }
            }
        }
    }
    return _DataHandled;
}
Beispiel #19
0
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()); //записываем значение в результат
}
void Qt_SetBacklight(uint8 light)
{
  if( light )
    m_background = QColor(Qt::white);
  else
    m_background = QColor(Qt::lightGray);
  if( m_window )
  {
    m_window->m_image.setColor(0,m_background.rgb());
    m_window->repaint();
  }
}
Beispiel #21
0
QColor blendColors(const QColor &bgColor, const QColor &fgColor)
{
	
	uint fg_r = fgColor.red();
	uint fg_g = fgColor.green();
	uint fg_b = fgColor.blue();
	uint fg_a = qAlpha(fgColor.rgb());
	
	uint bg_r = bgColor.red();
	uint bg_g = bgColor.green();
	uint bg_b = bgColor.blue();
	uint bg_a = qAlpha(bgColor.rgb());
	
	uint ac = 65025 - (255 - fg_a) * (255 - bg_a);
	uint res_r = ((255 - fg_a) * bg_r * bg_a + fg_a * fg_r  * 255 + 127) / ac;
	uint res_g = ((255 - fg_a) * bg_g * bg_a + fg_a * fg_g  * 255 + 127) / ac;
	uint res_b = ((255 - fg_a) * bg_b * bg_a + fg_a * fg_b  * 255 + 127) / ac;
	uint res_a = (ac+127)/255;
	
	return QColor(qRgba(res_r,res_g, res_b, res_a ));
}
Beispiel #22
0
const QString TagDefs::labelStyleSheet(const QColor &color)
{
    /* calculate best text color */
    QRgb textColor;
    if (qGray(color.rgb()) < 128) {
        /* dark color, use white */
        textColor = qRgb(255, 255, 255);
    } else {
        /* light color, use black */
        textColor = qRgb(0, 0, 0);
    }

    QColor colorBorder = color.darker(120);
    QColor colorGradient = color.lighter(150);

    return QString("QLabel{padding-left: 2px; padding-right: 2px; color: #%1; background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 #%2, stop:1 #%3); border-radius: 3px; border-color: #%4; border-width: 1; border-style: solid}")
            .arg(textColor & RGB_MASK, 6, 16, QChar('0'))
            .arg(colorGradient.rgb() & RGB_MASK, 6, 16, QChar('0'))
            .arg(color.rgb() & RGB_MASK, 6, 16, QChar('0'))
            .arg(colorBorder.rgb() & RGB_MASK, 6, 16, QChar('0'));
}
Beispiel #23
0
void KisColorSelectorRing::colorCache()
{
    Q_ASSERT(m_cachedColorSpace);
    m_cachedColors.clear();
    KoColor koColor;
    QColor qColor;
    for(int i=0; i<360; i++) {
        koColor = m_parent->converter()->fromHsvF(1.0 * i / 360.0, 1.0, 1.0);
        qColor = m_parent->converter()->toQColor(koColor);
        m_cachedColors.append(qColor.rgb());
    }
}
Beispiel #24
0
void ColorBox::addLastUsedColor(const QColor &color)
{
	if(m_lastused->count()>0 && m_lastused->color(0).color.rgb() == color.rgb())
		return;

	m_lastused->setWriteProtected(false);

	// Move color to the front of the palette
	m_lastused->insertColor(0, color);
	for(int i=1;i<m_lastused->count();++i) {
		if(m_lastused->color(i).color.rgb() == color.rgb()) {
			m_lastused->removeColor(i);
			break;
		}
	}

	// Limit maximum number of remembered colors
	if(m_lastused->count() > 24)
		m_lastused->removeColor(24);
	m_lastused->setWriteProtected(true);
}
void MoodLampManager::setCurrentColor(QColor color)
{
    DEBUG_MID_LEVEL << Q_FUNC_INFO << color;

    m_currentColor = color;

    if (m_isMoodLampEnabled && (m_isLiquidMode == false))
    {
        fillColors(color.rgb());
        emit updateLedsColors(m_colors);
    }
}
Beispiel #26
0
void FormStyle::GlobalColorButtonCliked()
{
	QColor initialColor;
	if ( focusWidget()->objectName() == "bC1_1" )
		initialColor = applicationPalette.button().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_2" )
		initialColor = applicationPalette.window().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_3" )
		initialColor = applicationPalette.shadow().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_4" )
		initialColor = applicationPalette.highlight().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_5" )
		initialColor = applicationPalette.base().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_6" )
		initialColor = applicationPalette.text().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_7" )
		initialColor = applicationPalette.highlightedText().color().rgba();
	else if ( focusWidget()->objectName() == "bC1_8" )
		initialColor = sliderButtonColor.rgb();
	else
		initialColor = Qt::white;

	QColor color = QColorDialog::getColor( initialColor, this, Texts[ 119 ] /*Wybierz kolor*/, QColorDialog::DontUseNativeDialog );

	if ( !color.isValid() )
		return;

	if ( focusWidget()->objectName() == "bC1_1" )
		applicationPalette.setBrush( QPalette::Button, color );
	else if ( focusWidget()->objectName() == "bC1_2" )
		applicationPalette.setBrush( QPalette::Window, color );
	else if ( focusWidget()->objectName() == "bC1_3" )
	{
		applicationPalette.setBrush( QPalette::Shadow, color );
		applicationPalette.setBrush( QPalette::Light, color );
		applicationPalette.setBrush( QPalette::Dark, color );
	} else if ( focusWidget()->objectName() == "bC1_4" )
		applicationPalette.setBrush( QPalette::Highlight, color );
	else if ( focusWidget()->objectName() == "bC1_5" )
		applicationPalette.setBrush( QPalette::Base, color );
	else if ( focusWidget()->objectName() == "bC1_6" )
	{
		applicationPalette.setBrush( QPalette::Text, color );
		applicationPalette.setBrush( QPalette::WindowText, color );
		applicationPalette.setBrush( QPalette::ButtonText, color );
	} else if ( focusWidget()->objectName() == "bC1_7" )
		applicationPalette.setBrush( QPalette::HighlightedText, color );
	else if ( focusWidget()->objectName() == "bC1_8" )
		sliderButtonColor = color;

	setButtonsColor();
}
Beispiel #27
0
/**
 * @brief Canvas::paint
 * @brief 铅笔工具的绘制函数
 * @param center 表示鼠标点击的中心
 * @param radius 表示铅笔的有效半径
 * @param color 表示铅笔的绘制颜色
 * @return 没有返回值
 */
void Canvas::paint(const QPoint center, const int radius,const QColor color){
    LayerItem* currentDisplayLayerItem = this->layerManager->getDisplayLayerItem();

    for(int x = center.x()-radius; x < center.x()+radius; x++){
        for(int y = center.y()-radius; y < center.y()+radius; y++){
            if(Util::calcL2Distance(center, QPoint(x,y)) < radius){
                currentDisplayLayerItem->image.setPixel(x, y,color.rgb());
            }
        }
    }

    this->update();
}
Beispiel #28
0
void YviColorShower::setHsv(int h, int s, int v)
{
    if (h < -1 || (uint)s > 255 || (uint)v > 255)
        return;

    m_hue = h; m_val = v; m_sat = s;
    QColor c;
    c.setHsv(m_hue, m_sat, m_val);
    m_curCol = c.rgb();

    showCurrentColor();
    //updateQColor();
}
Beispiel #29
0
void PainterWidget::clear()
{
  //  image.fill(qRgb(255,255,255));
    for(int i = 0; i < 256; i++)
    {
        for(int j = 0; j < 256; j++)
        {
            float v = float(j);
            QColor c = QColor(v,v,v);
            image.setPixel(i,j,c.rgb());
        }
    }
}
Beispiel #30
0
void imageViewer::createImage(QSize sz,QColor fill,bool scale)
{
  clear();
  displayedImage=QImage(sz,QImage::Format_ARGB32_Premultiplied);
  if(!displayedImage.isNull())
  {
    displayedImage.fill(fill.rgb());
    useCompression=false;
  }
  stretch=scale;
  displayImage();
  emit imageChanged();
}