Exemple #1
0
void BarcodeGenerator::paintColorSample(QLabel *l, const ScColor & c)
{
	QRect rect = l->frameRect();
	QPixmap pm(rect.width(), rect.height());
	pm.fill(c.getRawRGBColor()); // brute force sc2qt color convert for preview
	l->setPixmap(pm);
}
bool ColorListBox::event(QEvent *event)
{
    if (event->type() == QEvent::ToolTip)
    {
        if (cList != NULL)
        {
            QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
            QListWidgetItem* it = itemAt(helpEvent->pos());
            if (it != 0)
            {
                event->accept();
                QString tipText = "";
                if (cList->contains(it->text()))
                {
                    ScColor col = (*cList)[it->text()];
                    if (col.getColorModel() == colorModelCMYK)
                    {
                        int c, m, y, k;
                        col.getCMYK(&c, &m, &y, &k);
                        tipText = QString("C:%1% M:%2% Y:%3% K:%4%").arg(qRound(c / 2.55)).arg(qRound(m / 2.55)).arg(qRound(y / 2.55)).arg(qRound(k / 2.55));
                    }
                    else
                    {
                        int r, g, b;
                        col.getRawRGBColor(&r, &g, &b);
                        tipText = QString("R:%1 G:%2 B:%3").arg(r).arg(g).arg(b);
                    }
                }
                QToolTip::showText(helpEvent->globalPos(), tipText, this);
                return true;
            }
        }
    }
    return QListWidget::event(event);
}
Exemple #3
0
void ScColorEngine::getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColorF& rgb, double level)
{
	if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColorF cmyk;
		getShadeColorCMYK(color, doc, cmyk, level);
		ScColor tmpC;
		tmpC.setColorF(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
		getRGBValues(tmpC, doc, rgb);
	}
	else if (color.getColorModel() == colorModelRGB)
	{
		HSVColorF hsv;
		color.getRawRGBColor(&rgb);
		rgb.toHsv(hsv);
		hsv.s = hsv.s * (level / 100.0);
		hsv.v = 1.0 - (1.0 - hsv.v) * (level / 100.0);
		hsv.toRgb(rgb);
		//We could also compute rgb shade using rgb directly
		/*rgb.r = 1.0 - ((1.0 - color.m_values[0]) * level / 100);
		rgb.g = 1.0 - ((1.0 - color.m_values[1]) * level / 100);
		rgb.b = 1.0 - ((1.0 - color.m_values[2]) * level / 100);*/
	}
	else if (color.getColorModel() == colorModelLab)
	{
		ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
		double inC[3];
		inC[0] = 100 - (100 - color.m_L_val) * (level / 100.0);
		inC[1] = color.m_a_val * (level / 100.0);
		inC[2] = color.m_b_val * (level / 100.0);
		quint16 outC[3];
		trans.apply(inC, outC, 1);
		rgb.r = outC[0] / 65535.0;
		rgb.g = outC[1] / 65535.0;
		rgb.b = outC[2] / 65535.0;
	}
}