Exemple #1
0
void CMYKChoose::selFromSwatch(QListWidgetItem* c)
{
	disconnect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(selModel(const QString&)));
	ScColor tmp = CurrSwatch[c->text()];
	if (isRegistration)
	{
		if (tmp.getColorModel() != colorModelCMYK)
			tmp = ScColorEngine::convertToModel(tmp, m_doc, colorModelCMYK);
		selModel( tr("CMYK"));
	}
	else
	{
		if (tmp.getColorModel() == colorModelCMYK)
		{
			ComboBox1->setCurrentIndex( 0 );
			selModel( tr("CMYK"));
		}
		else
		{
			ComboBox1->setCurrentIndex( 1 );
			selModel( tr("RGB"));
		}
	}
	imageN.fill( ScColorEngine::getDisplayColor(tmp, m_doc) );
	if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
		paintAlert(alertIcon, imageN, 2, 2, false);
	NewC->setPixmap( imageN );
	Farbe = tmp;
	setValues();
	Separations->setChecked(tmp.isSpotColor());
	if ((isNew) && (!ColorName->isModified()))
		ColorName->setText(c->text());
	connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(selModel(const QString&)));
}
Exemple #2
0
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc, double level)
{
	QColor tmp;
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColorF rgb;
		rgb.r = color.m_values[0];
		rgb.g = color.m_values[1];
		rgb.b = color.m_values[2];
		getShadeColorRGB(color, doc, rgb, level);
		tmp = getDisplayColor(rgb, doc, color.isSpotColor());
	}
	else if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColorF cmyk;
		cmyk.c = color.m_values[0];
		cmyk.m = color.m_values[1];
		cmyk.y = color.m_values[2];
		cmyk.k = color.m_values[3];
		getShadeColorCMYK(color, doc, cmyk, level);
		tmp = getDisplayColor(cmyk, doc, color.isSpotColor());
	}
	else if (color.getColorModel() == colorModelLab)
	{
		ScColorTransform trans  = doc ? doc->stdLabToScreenTrans : 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);
		tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257);
	}
	return tmp;
}
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc)
{
	QColor tmp;
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColor rgb;
		rgb.r = color.CR;
		rgb.g = color.MG;
		rgb.b = color.YB;
		tmp = getDisplayColor(rgb, doc, color.isSpotColor());
	}
	else if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColor cmyk;
		cmyk.c = color.CR;
		cmyk.m = color.MG;
		cmyk.y = color.YB;
		cmyk.k = color.K;
		tmp = getDisplayColor(cmyk, doc, color.isSpotColor());
	}
	else if (color.getColorModel() == colorModelLab)
	{
		ScColorTransform trans  = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
		double inC[3];
		inC[0] = color.L_val;
		inC[1] = color.a_val;
		inC[2] = color.b_val;
		quint16 outC[3];
		trans.apply(inC, outC, 1);
		tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257);
	}
	return tmp;
}
Exemple #4
0
static quint64 code64(const ScColor & col) {
	int C, M, Y, K, R, G, B;
	quint64 result=0;
	if (col.getColorModel() == colorModelRGB)
	{
		col.getRGB( &R, &G, &B );
		QColor color = QColor(R, G, B);
		color.getCmyk(&C, &M, &Y, &K);
	}
	else
	{
		col.getCMYK( &C, &M, &Y, &K );
		R = 255-qMin(255, C + K);
		G = 255-qMin(255, M + K);
		B = 255-qMin(255, Y + K);
	}
	result |= col.getColorModel() == colorModelRGB ? 1 : 0;
	result |= col.isSpotColor() ? 64 : 0;
	result |= col.isRegistrationColor() ? 32 : 0;
	result <<= 8;
	result |= C;
	result <<= 8;
	result |= M;
	result <<= 8;
	result |= Y;
	result <<= 8;
	result |= K;
	result <<= 8;
	result |= R;
	result <<= 8;
	result |= G;
	result <<= 8;
	result |= B;
	return result;
}
Exemple #5
0
void ScColorEngine::getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc, CMYKColorF& cmyk, double level)
{
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColorF rgb;
		getShadeColorRGB(color, doc, rgb, level);
		ScColor tmpR;
		tmpR.setRgbColorF(rgb.r, rgb.g, rgb.b);
		getCMYKValues(tmpR, doc, cmyk);
	}
	else if (color.getColorModel() == colorModelCMYK)
	{
		cmyk.c = color.m_values[0] * level / 100.0;
		cmyk.m = color.m_values[1] * level / 100.0;
		cmyk.y = color.m_values[2] * level / 100.0;
		cmyk.k = color.m_values[3] * level / 100.0;
	}
	else if (color.getColorModel() == colorModelLab)
	{
		ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
		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[4];
		trans.apply(inC, outC, 1);
		cmyk.c = outC[0] / 65535.0;
		cmyk.m = outC[1] / 65535.0;
		cmyk.y = outC[2] / 65535.0;
		cmyk.k = outC[3] / 65535.0;
	}
}
void ScColorEngine::getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc, 
										  CMYKColor& cmyk, double level)
{
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColor rgb;
		getShadeColorRGB(color, doc, rgb, level);
		ScColor tmpR(rgb.r, rgb.g, rgb.b);
		getCMYKValues(tmpR, doc, cmyk);
	}
	else if (color.getColorModel() == colorModelCMYK)
	{
		cmyk.c = qRound(color.CR * level / 100.0);
		cmyk.m = qRound(color.MG * level / 100.0);
		cmyk.y = qRound(color.YB * level / 100.0);
		cmyk.k = qRound(color.K * level / 100.0);
	}
	else if (color.getColorModel() == colorModelLab)
	{
		ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
		double inC[3];
		inC[0] = color.L_val * (level / 100.0);
		inC[1] = color.a_val;
		inC[2] = color.b_val;
		quint16 outC[4];
		trans.apply(inC, outC, 1);
		cmyk.c = outC[0] / 257;
		cmyk.m = outC[1] / 257;
		cmyk.y = outC[2] / 257;
		cmyk.k = outC[3] / 257;
	}
}
Exemple #7
0
bool ScColorEngine::isOutOfGamut(const ScColor& color, const ScribusDoc* doc)
{
	bool outOfGamutFlag = false;
	if (color.isSpotColor())
		return false;
	unsigned short inC[4];
	unsigned short outC[4];
	bool cmsUse = doc ? doc->HasCMS : false;
	if (ScCore->haveCMS() && cmsUse)
	{
		bool alert = true;
		ScColorTransform xformProof;
		if (color.getColorModel() == colorModelRGB)
		{
			inC[0] = qRound(color.m_values[0] * 65535.0);
			inC[1] = qRound(color.m_values[1] * 65535.0);
			inC[2] = qRound(color.m_values[2] * 65535.0);
			xformProof = doc->stdProofGC;
			if ((color.m_values[0] == 0) && (color.m_values[1] == 0) && (color.m_values[2] == 1.0))
				alert = false;
			if ((color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2]))
				alert = false;
		}
		else if (color.getColorModel() == colorModelCMYK)
		{
			inC[0] = qRound(color.m_values[0] * 65535.0);
			inC[1] = qRound(color.m_values[1] * 65535.0);
			inC[2] = qRound(color.m_values[2] * 65535.0);
			inC[3] = qRound(color.m_values[3] * 65535.0);
			xformProof = doc->stdProofCMYKGC;
			if ((color.m_values[0] == 1.0) && (color.m_values[1] == 0) && (color.m_values[3] == 0) && (color.m_values[2] == 1.0))
				alert = false;
			if ((color.m_values[0] == 0.0) && (color.m_values[1] == 0) && (color.m_values[2] == 0))
				alert = false;
			if ((color.m_values[0] == color.m_values[1]) && (color.m_values[0] == color.m_values[2]) && (color.m_values[2] == color.m_values[3]))
				alert = false;
		}
		else if (color.getColorModel() == colorModelLab)
		{
			double inC[3];
			inC[0] = color.m_L_val;
			inC[1] = color.m_a_val;
			inC[2] = color.m_b_val;
			xformProof = doc->stdProofLabGC;
			xformProof.apply(inC, outC, 1);
			if ((outC[0]/257 == 0) && (outC[1]/257 == 255) && (outC[2]/257 == 0))
				outOfGamutFlag = true;
			alert = false;
		}
		if (alert)
		{
			xformProof.apply(inC, outC, 1);
			if ((outC[0]/257 == 0) && (outC[1]/257 == 255) && (outC[2]/257 == 0))
				outOfGamutFlag = true;
		}
	}
	return outOfGamutFlag;
}
bool ScColorEngine::isOutOfGamut(const ScColor& color, const ScribusDoc* doc)
{
	bool outOfGamutFlag = false;
	if (color.isSpotColor())
		return false;
	unsigned short inC[4];
	unsigned short outC[4];
	bool cmsUse = doc ? doc->HasCMS : false;
	if (ScCore->haveCMS() && cmsUse)
	{
		bool alert = true;
		ScColorTransform xformProof;
		if (color.getColorModel() == colorModelRGB)
		{
			inC[0] = color.CR * 257;
			inC[1] = color.MG * 257;
			inC[2] = color.YB * 257;
			xformProof = doc->stdProofGC;
			if ((color.CR == 0) && (color.YB == 0) && (color.MG == 255))
				alert = false;
			if ((color.CR == color.MG && color.MG == color.YB))
				alert = false;
		}
		else if (color.getColorModel() == colorModelCMYK)
		{
			inC[0] = color.CR * 257;
			inC[1] = color.MG * 257;
			inC[2] = color.YB * 257;
			inC[3] = color.K * 257;
			xformProof = doc->stdProofCMYKGC;
			if ((color.MG == 0) && (color.K == 0) && (color.CR == 255) && (color.YB == 255))
				alert = false;
			if ((color.MG == 0) && (color.CR == 0) && (color.YB == 0))
				alert = false;
			if ((color.MG == color.CR) && (color.CR == color.YB) && (color.YB == color.K))
				alert = false;
		}
		else if (color.getColorModel() == colorModelLab)
		{
			double inC[3];
			inC[0] = color.L_val;
			inC[1] = color.a_val;
			inC[2] = color.b_val;
			xformProof = doc->stdProofLabGC;
			xformProof.apply(inC, outC, 1);
			if ((outC[0]/257 == 0) && (outC[1]/257 == 255) && (outC[2]/257 == 0))
				outOfGamutFlag = true;
			alert = false;
		}
		if (alert)
		{
			xformProof.apply(inC, outC, 1);
			if ((outC[0]/257 == 0) && (outC[1]/257 == 255) && (outC[2]/257 == 0))
				outOfGamutFlag = true;
		}
	}
	return outOfGamutFlag;
}
Exemple #9
0
static quint64 code64(const ScColor & col)
{
	int C = 0;
	int M = 0;
	int Y = 0;
	int K = 0;
	int R = 0;
	int G = 0;
	int B = 0;
	quint64 result = 0;
	if (col.getColorModel() == colorModelRGB)
	{
		col.getRGB( &R, &G, &B );
		QColor color = QColor(R, G, B);
		color.getCmyk(&C, &M, &Y, &K);
	}
	else if (col.getColorModel() == colorModelCMYK)
	{
		col.getCMYK( &C, &M, &Y, &K );
		R = 255-qMin(255, C + K);
		G = 255-qMin(255, M + K);
		B = 255-qMin(255, Y + K);
	}
	else
	{
		double L, a, b;
		col.getLab(&L, &a, &b);
		R = qRound(L);
		G = qRound(a);
		B = qRound(b);
	}
	result |= col.getColorModel() == colorModelRGB ? 1 : 0;
	result |= col.isSpotColor() ? 64 : 0;
	result |= col.isRegistrationColor() ? 32 : 0;
	result <<= 8;
	result |= C;
	result <<= 8;
	result |= M;
	result <<= 8;
	result |= Y;
	result <<= 8;
	result |= K;
	result <<= 8;
	result |= R;
	result <<= 8;
	result |= G;
	result <<= 8;
	result |= B;
	return result;
}
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 #11
0
QColor ScColorEngine::getColorProof(const ScColor& color, const ScribusDoc* doc, bool gamutCheck)
{
	QColor tmp;
	bool gamutChkEnabled = doc ? doc->Gamut : false;
	bool spot = color.isSpotColor();
	if (color.getColorModel() == colorModelRGB)
	{
		// Match 133x behavior (RGB greys map to cmyk greys) until we are able to make rgb profiled output
		if (color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2])
			gamutChkEnabled = false;
		RGBColor rgb;
		rgb.r = qRound(color.m_values[0] * 255.0);
		rgb.g = qRound(color.m_values[1] * 255.0);
		rgb.b = qRound(color.m_values[2] * 255.0);
		tmp = getColorProof(rgb, doc, spot, gamutCheck & gamutChkEnabled);
	}
	else
	{
		CMYKColor cmyk;
		cmyk.c = qRound(color.m_values[0] * 255.0);
		cmyk.m = qRound(color.m_values[1] * 255.0);
		cmyk.y = qRound(color.m_values[2] * 255.0);
		cmyk.k = qRound(color.m_values[3] * 255.0);
		tmp = getColorProof(cmyk, doc, spot, gamutCheck & gamutChkEnabled);
	}
	return tmp;
}
Exemple #12
0
QColor ScColorEngine::getColorProof(const ScColor& color, const ScribusDoc* doc, bool gamutCheck)
{
	QColor tmp;
	bool gamutChkEnabled = doc ? doc->Gamut : false;
	bool spot = color.isSpotColor();
	if (color.getColorModel() == colorModelRGB)
	{
		// Match 133x behavior (RGB greys map to cmyk greys) until we are able to make rgb profiled output
		if ( color.CR == color.MG && color.MG == color.YB )
			gamutChkEnabled = false;
		RGBColor rgb;
		rgb.r = color.CR;
		rgb.g = color.MG;
		rgb.b = color.YB;
		tmp = getColorProof(rgb, doc, spot, gamutCheck & gamutChkEnabled);
	}
	else
	{
		CMYKColor cmyk;
		cmyk.c = color.CR;
		cmyk.m = color.MG;
		cmyk.y = color.YB;
		cmyk.k = color.K;
		tmp = getColorProof(cmyk, doc, spot, gamutCheck & gamutChkEnabled);
	}
	return tmp;
}
Exemple #13
0
ScColor ScColorEngine::convertToModel(const ScColor& color, const ScribusDoc* doc, colorModel model)
{
	colorModel oldModel = color.getColorModel();
	if (oldModel == model)
		return ScColor(color);
	ScColor newCol;
	if (model == colorModelRGB)
	{
		RGBColorF rgb;
		getRGBValues(color, doc, rgb);
		newCol.setRgbColorF(rgb.r, rgb.g, rgb.b);
	}
	else if (model == colorModelCMYK)
	{
		CMYKColorF cmyk;
		getCMYKValues(color, doc, cmyk);
		newCol.setColorF(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
	}
	else if (model == colorModelLab)
	{
		ScColorMgmtEngine engine(ScCore->defaultEngine);
		if (oldModel == colorModelRGB)
		{
			ScColorProfile profRGB = doc ? doc->DocInputRGBProf : ScCore->defaultRGBProfile;
			ScColorProfile profLab = ScCore->defaultLabProfile;
			ScColorTransform trans = engine.createTransform(profRGB, Format_RGB_16, profLab, Format_Lab_Dbl, Intent_Perceptual, 0);
			double outC[3];
			unsigned short inC[3];
			inC[0] = qRound(color.m_values[0] * 65535);
			inC[1] = qRound(color.m_values[1] * 65535);
			inC[2] = qRound(color.m_values[2] * 65535);
			trans.apply(inC, outC, 1);
			newCol.setLabColor(outC[0], outC[1], outC[2]);
		}
		else
		{
			ScColorProfile profCMYK = doc ? doc->DocInputCMYKProf : ScCore->defaultCMYKProfile;
			ScColorProfile profLab = ScCore->defaultLabProfile;
			ScColorTransform trans = engine.createTransform(profCMYK, Format_CMYK_16, profLab, Format_Lab_Dbl, Intent_Perceptual, 0);
			double outC[3];
			unsigned short inC[4];
			inC[0] = qRound(color.m_values[0] * 65535);
			inC[1] = qRound(color.m_values[1] * 65535);
			inC[2] = qRound(color.m_values[2] * 65535);
			inC[3] = qRound(color.m_values[3] * 65535);
			trans.apply(inC, outC, 1);
			newCol.setLabColor(outC[0], outC[1], outC[2]);
		}
	}
	return newCol;
}
Exemple #14
0
void ScColorEngine::getCMYKValues(const ScColor& color, const ScribusDoc* doc, CMYKColor& cmyk)
{
	unsigned short inC[4];
	unsigned short outC[4];
	colorModel model = color.getColorModel();
	ScColorTransform transCMYK = doc ? doc->stdTransCMYK : ScCore->defaultRGBToCMYKTrans;
	if (ScCore->haveCMS() && transCMYK)
	{
		if (model == colorModelRGB)
		{
			// allow RGB greys to go got to CMYK greys without transform
			if (color.CR == color.MG && color.MG == color.YB)
			{
				cmyk.c = cmyk.m = cmyk.y = 0;
				cmyk.k = 255 - color.CR;
			}
			else
			{
				inC[0] = color.CR * 257;
				inC[1] = color.MG * 257;
				inC[2] = color.YB * 257;
				transCMYK.apply(inC, outC, 1);
				cmyk.c = outC[0] / 257;
				cmyk.m = outC[1] / 257;
				cmyk.y = outC[2] / 257;
				cmyk.k = outC[3] / 257;
			}
		}
		else
		{
			cmyk.c = color.CR;
			cmyk.m = color.MG;
			cmyk.y = color.YB;
			cmyk.k = color.K;
		}
	}
	else if (model == colorModelRGB)
	{
		cmyk.k = qMin(qMin(255 - color.CR, 255 - color.MG), 255 - color.YB);
		cmyk.c = 255 - color.CR - cmyk.k;
		cmyk.m = 255 - color.MG - cmyk.k;
		cmyk.y = 255 - color.YB - cmyk.k;
	}
	else
	{
		cmyk.c = color.CR;
		cmyk.m = color.MG;
		cmyk.y = color.YB;
		cmyk.k = color.K;
	}
}
Exemple #15
0
void ScColorEngine::applyGCR(ScColor& color, const ScribusDoc* doc)
{
	bool cmsUse = doc ? doc->HasCMS : false;
	if (!(ScCore->haveCMS() && cmsUse) && (color.getColorModel() != colorModelLab))
	{
		CMYKColor cmyk;
		getCMYKValues(color, doc, cmyk);
		int k = qMin(qMin(cmyk.c, cmyk.m), cmyk.y);
		color.m_values[0] = (cmyk.c - k) / 255.0;
		color.m_values[1] = (cmyk.m - k) / 255.0;
		color.m_values[2] = (cmyk.y - k) / 255.0;
		color.m_values[3] = qMin((cmyk.k + k) / 255.0, 1.0);
	}
}
void ScColorEngine::applyGCR(ScColor& color, const ScribusDoc* doc)
{
	bool cmsUse = doc ? doc->HasCMS : false;
	if (!(ScCore->haveCMS() && cmsUse) && (color.getColorModel() != colorModelLab))
	{
		CMYKColor cmyk;
		getCMYKValues(color, doc, cmyk);
		int k = qMin(qMin(cmyk.c, cmyk.m), cmyk.y);
		color.CR = cmyk.c - k;
		color.MG = cmyk.m - k;
		color.YB = cmyk.y - k;
		color.K = qMin((cmyk.k + k), 255);
	}
}
void ScColorEngine::getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColor& rgb, double level)
{
	if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColor cmyk;
		getShadeColorCMYK(color, doc, cmyk, level);
		ScColor tmpC(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
		getRGBValues(tmpC, doc, rgb);
	}
	else if (color.getColorModel() == colorModelRGB)
	{
		int h, s, v, snew, vnew;
		QColor tmpR(color.CR, color.MG, color.YB);
		tmpR.getHsv(&h, &s, &v);
		snew = qRound(s * level / 100.0);
		vnew = 255 - qRound(((255 - v) * level / 100.0));
		tmpR.setHsv(h, snew, vnew);
		tmpR.getRgb(&rgb.r, &rgb.g, &rgb.b);
		//We could also compute rgb shade using rgb directly
		/*rgb.CR = 255 - ((255 - color.CR) * level / 100);
		rgb.MG = 255 - ((255 - color.MG) * level / 100);
		rgb.YB = 255 - ((255 - color.YB) * level / 100);*/
	}
	else if (color.getColorModel() == colorModelLab)
	{
		ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
		double inC[3];
		inC[0] = color.L_val * (level / 100.0);
		inC[1] = color.a_val;
		inC[2] = color.b_val;
		quint16 outC[3];
		trans.apply(inC, outC, 1);
		rgb.r = outC[0] / 257;
		rgb.g = outC[1] / 257;
		rgb.b = outC[2] / 257;
	}
}
Exemple #18
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;
	}
}
Exemple #19
0
void ScColorEngine::getShadeColorCMYK(const ScColor& color, const ScribusDoc* doc, 
										  CMYKColor& cmyk, double level)
{
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColor rgb;
		getShadeColorRGB(color, doc, rgb, level);
		ScColor tmpR(rgb.r, rgb.g, rgb.b);
		getCMYKValues(tmpR, doc, cmyk);
	}
	else
	{
		cmyk.c = qRound(color.CR * level / 100.0);
		cmyk.m = qRound(color.MG * level / 100.0);
		cmyk.y = qRound(color.YB * level / 100.0);
		cmyk.k = qRound(color.K * level / 100.0);
	}
}
Exemple #20
0
ScColor ScColorEngine::convertToModel(const ScColor& color, const ScribusDoc* doc, colorModel model)
{
	colorModel oldModel = color.getColorModel();
	if( oldModel == model )
		return ScColor(color);
	ScColor newCol;
	if( model == colorModelRGB )
	{
		RGBColor rgb;
		getRGBValues(color, doc, rgb);
		newCol.setColorRGB(rgb.r, rgb.g, rgb.b);
	}
	else
	{
		CMYKColor cmyk;
		getCMYKValues(color, doc, cmyk);
		newCol.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
	}
	return newCol;
}
Exemple #21
0
QColor ScColorEngine::getShadeColorProof(const ScColor& color, const ScribusDoc* doc, double level)
{
	QColor tmp;
	bool doGC = doc ? doc->Gamut : false;
	bool cmsUse = doc ? doc->HasCMS : false;
	bool softProof = doc ? doc->SoftProofing : false;

	if (color.getColorModel() == colorModelRGB)
	{
		RGBColor rgb;
		rgb.r = color.CR;
		rgb.g = color.MG;
		rgb.b = color.YB;
		getShadeColorRGB(color, doc, rgb, level);
		// Match 133x behavior for rgb grey until we are able to make rgb profiled output
		// (RGB greys map to cmyk greys)
		if ((cmsUse && softProof) && (rgb.r == rgb.g && rgb.g == rgb.b))
		{
			doGC = false;
			CMYKColor cmyk;
			cmyk.c = cmyk.m = cmyk.y = 0;
			cmyk.k = 255 - rgb.g;
			tmp = getColorProof(cmyk, doc, color.isSpotColor(), doGC);
		}
		else
			tmp = getColorProof(rgb, doc, color.isSpotColor(), doGC);
	}
	else
	{
		CMYKColor cmyk;
		cmyk.c = color.CR;
		cmyk.m = color.MG;
		cmyk.y = color.YB;
		cmyk.k = color.K;
		getShadeColorCMYK(color, doc, cmyk, level);
		tmp = getColorProof(cmyk, doc, color.isSpotColor(), doGC);
	}
	
	return tmp;
}
Exemple #22
0
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc)
{
	QColor tmp;
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColor rgb;
		rgb.r = color.CR;
		rgb.g = color.MG;
		rgb.b = color.YB;
		tmp = getDisplayColor(rgb, doc, color.isSpotColor());
	}
	else
	{
		CMYKColor cmyk;
		cmyk.c = color.CR;
		cmyk.m = color.MG;
		cmyk.y = color.YB;
		cmyk.k = color.K;
		tmp = getDisplayColor(cmyk, doc, color.isSpotColor());
	}
	return tmp;
}
Exemple #23
0
void ScColorEngine::getRGBValues(const ScColor& color, const ScribusDoc* doc, RGBColor& rgb)
{
	colorModel    model = color.getColorModel();
	ScColorTransform transRGB = doc ? doc->stdTransRGB : ScCore->defaultCMYKToRGBTrans;
	if (ScCore->haveCMS() && transRGB)
	{
		if (model == colorModelRGB)
		{
			rgb.r = color.CR;
			rgb.g = color.MG;
			rgb.b = color.YB;
		}
		else
		{
			unsigned short inC[4];
			unsigned short outC[4];
			inC[0] = color.CR * 257;
			inC[1] = color.MG * 257;
			inC[2] = color.YB * 257;
			inC[3] = color.K * 257;
			transRGB.apply(inC, outC, 1);
			rgb.r = outC[0] / 257;
			rgb.g = outC[1] / 257;
			rgb.b = outC[2] / 257;
		}
	}
	else if (model == colorModelCMYK)
	{
		rgb.r = 255 - qMin(255, color.CR + color.K);
		rgb.g = 255 - qMin(255, color.MG + color.K);
		rgb.b = 255 - qMin(255, color.YB + color.K);
	}
	else
	{
		rgb.r = color.CR;
		rgb.g = color.MG;
		rgb.b = color.YB;
	}
}
Exemple #24
0
static quint64 code64(const ScColor & col) {
	int C, M, Y, K, R, G, B;
	quint64 result=0;
	col.getRGB( &R, &G, &B );
	col.getCMYK( &C, &M, &Y, &K );
	result |= col.getColorModel() == colorModelRGB ? 1 : 0;
	result |= col.isSpotColor() ? 64 : 0;
	result |= col.isRegistrationColor() ? 32 : 0;
	result <<= 8;
	result |= C;
	result <<= 8;
	result |= M;
	result <<= 8;
	result |= Y;
	result <<= 8;
	result |= K;
	result <<= 8;
	result |= R;
	result <<= 8;
	result |= G;
	result <<= 8;
	result |= B;
	return result;
}
Exemple #25
0
void ScColorEngine::getShadeColorRGB(const ScColor& color, const ScribusDoc* doc, RGBColor& rgb, double level)
{
	if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColor cmyk;
		getShadeColorCMYK(color, doc, cmyk, level);
		ScColor tmpC(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
		getRGBValues(tmpC, doc, rgb);
	}
	else
	{
		int h, s, v, snew, vnew;
		QColor tmpR(color.CR, color.MG, color.YB);
		tmpR.getHsv(&h, &s, &v);
		snew = qRound(s * level / 100.0);
		vnew = 255 - qRound(((255 - v) * level / 100.0));
		tmpR.setHsv(h, snew, vnew);
		tmpR.getRgb(&rgb.r, &rgb.g, &rgb.b);
		//We could also compute rgb shade using rgb directly
		/*rgb.CR = 255 - ((255 - color.CR) * level / 100);
		rgb.MG = 255 - ((255 - color.MG) * level / 100);
		rgb.YB = 255 - ((255 - color.YB) * level / 100);*/
	}
}
Exemple #26
0
void ScColorEngine::getRGBValues(const ScColor& color, const ScribusDoc* doc, RGBColor& rgb)
{
	colorModel    model = color.getColorModel();
	ScColorTransform transRGB = doc ? doc->stdTransRGB : ScCore->defaultCMYKToRGBTrans;
	if (ScCore->haveCMS() && transRGB)
	{
		if (model == colorModelRGB)
		{
			rgb.r = qRound(color.m_values[0] * 255.0);
			rgb.g = qRound(color.m_values[1] * 255.0);
			rgb.b = qRound(color.m_values[2] * 255.0);
		}
		else if (model == colorModelCMYK)
		{
			unsigned short inC[4];
			unsigned short outC[4];
			inC[0] = qRound(color.m_values[0] * 65535);
			inC[1] = qRound(color.m_values[1] * 65535);
			inC[2] = qRound(color.m_values[2] * 65535);
			inC[3] = qRound(color.m_values[3] * 65535);
			transRGB.apply(inC, outC, 1);
			rgb.r = outC[0] / 257;
			rgb.g = outC[1] / 257;
			rgb.b = outC[2] / 257;
		}
		else if (model == colorModelLab)
		{
			ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
			double inC[3];
			inC[0] = color.m_L_val;
			inC[1] = color.m_a_val;
			inC[2] = color.m_b_val;
			quint16 outC[3];
			trans.apply(inC, outC, 1);
			rgb.r = outC[0] / 257;
			rgb.g = outC[1] / 257;
			rgb.b = outC[2] / 257;
		}
	}
	else if (model == colorModelCMYK)
	{
		double r = 1.0 - qMin(1.0, color.m_values[0] + color.m_values[3]);
		double g = 1.0 - qMin(1.0, color.m_values[1] + color.m_values[3]);
		double b = 1.0 - qMin(1.0, color.m_values[2] + color.m_values[3]);
		rgb.r = qRound(r * 255.0);
		rgb.g = qRound(g * 255.0);
		rgb.b = qRound(b * 255.0);
	}
	else if (model == colorModelRGB)
	{
		rgb.r = qRound(color.m_values[0] * 255.0);
		rgb.g = qRound(color.m_values[1] * 255.0);
		rgb.b = qRound(color.m_values[2] * 255.0);
	}
	else if (model == colorModelLab)
	{
		// First step: Lab -> XYZ
		double var_Y = (color.m_L_val + 16) / 116.0;
		double var_X = color.m_a_val / 500.0 + var_Y;
		double var_Z = var_Y - color.m_b_val / 200.0;
		if (pow(var_Y, 3) > 0.008856)
			var_Y = pow(var_Y, 3);
		else
			var_Y = (var_Y - 16.0 / 116.0) / 7.787;
		if (pow(var_X, 3) > 0.008856)
			var_X = pow(var_X, 3);
		else
			var_X = (var_X - 16.0 / 116.0) / 7.787;
		if (pow(var_Z, 3) > 0.008856)
			var_Z = pow(var_Z, 3);
		else
			var_Z = (var_Z - 16.0 / 116.0) / 7.787;
		// Second step: XYZ -> RGB
		// Whitepoint D50
		var_X = 0.990720 * var_X;
		var_Y = 1.00000  * var_Y;
		var_Z = 0.825210 * var_Z;
		double var_R = var_X *  3.2406 + var_Y * -1.5372 + var_Z * -0.4986;
		double var_G = var_X * -0.9689 + var_Y *  1.8758 + var_Z *  0.0415;
		double var_B = var_X *  0.0557 + var_Y * -0.2040 + var_Z *  1.0570;
		if (var_R > 0.0031308)
			var_R = 1.055 * (pow(var_R, (1.0 / 2.4))) - 0.055;
		else
			var_R = 12.92 * var_R;
		if (var_G > 0.0031308)
			var_G = 1.055 * (pow(var_G, (1.0 / 2.4))) - 0.055;
		else
			var_G = 12.92 * var_G;
		if (var_B > 0.0031308)
			var_B = 1.055 * (pow(var_B, (1.0 / 2.4))) - 0.055;
		else
			var_B = 12.92 * var_B;
		rgb.r = qRound(qMax(qMin(var_R, 1.0), 0.0) * 255.0);
		rgb.g = qRound(qMax(qMin(var_G, 1.0), 0.0) * 255.0);
		rgb.b = qRound(qMax(qMin(var_B, 1.0), 0.0) * 255.0);
	/*	ScColorTransform trans = doc ? doc->stdLabToRGBTrans : ScCore->defaultLabToRGBTrans;
		double inC[3];
		inC[0] = color.L_val;
		inC[1] = color.a_val;
		inC[2] = color.b_val;
		quint16 outC[3];
		trans.apply(inC, outC, 1);
		rgb.r = outC[0] / 257;
		rgb.g = outC[1] / 257;
		rgb.b = outC[2] / 257;*/
	}
}
Exemple #27
0
void ScColorEngine::getCMYKValues(const ScColor& color, const ScribusDoc* doc, CMYKColorF& cmyk)
{
	unsigned short inC[4];
	unsigned short outC[4];
	colorModel model = color.getColorModel();
	ScColorTransform transCMYK = doc ? doc->stdTransCMYK : ScCore->defaultRGBToCMYKTrans;
	if (ScCore->haveCMS() && transCMYK)
	{
		if (model == colorModelRGB)
		{
			// allow RGB greys to go to CMYK greys without transform
			if (color.m_values[0] == color.m_values[1] && color.m_values[1] == color.m_values[2])
			{
				cmyk.c = cmyk.m = cmyk.y = 0;
				cmyk.k = 1.0 - color.m_values[0];
			}
			else
			{
				inC[0] = qRound(color.m_values[0] * 65535.0);
				inC[1] = qRound(color.m_values[1] * 65535.0);
				inC[2] = qRound(color.m_values[2] * 65535.0);
				transCMYK.apply(inC, outC, 1);
				cmyk.c = outC[0] / 65535.0;
				cmyk.m = outC[1] / 65535.0;
				cmyk.y = outC[2] / 65535.0;
				cmyk.k = outC[3] / 65535.0;
			}
		}
		else if (model == colorModelCMYK)
		{
			cmyk.c = color.m_values[0];
			cmyk.m = color.m_values[1];
			cmyk.y = color.m_values[2];
			cmyk.k = color.m_values[3];
		}
		else if (model == colorModelLab)
		{
			ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
			double inC[3];
			inC[0] = color.m_L_val;
			inC[1] = color.m_a_val;
			inC[2] = color.m_b_val;
			quint16 outC[4];
			trans.apply(inC, outC, 1);
			cmyk.c = outC[0] / 65535.0;
			cmyk.m = outC[1] / 65535.0;
			cmyk.y = outC[2] / 65535.0;
			cmyk.k = outC[3] / 65535.0;
		}
	}
	else if (model == colorModelRGB)
	{
		cmyk.k = qMin(qMin(1.0 - color.m_values[0], 1.0 - color.m_values[1]), 1.0 - color.m_values[2]);
		cmyk.c = 1.0 - (color.m_values[0] - cmyk.k);
		cmyk.m = 1.0 - (color.m_values[1] - cmyk.k);
		cmyk.y = 1.0 - (color.m_values[2] - cmyk.k);
	}
	else if (model == colorModelCMYK)
	{
		cmyk.c = color.m_values[0];
		cmyk.m = color.m_values[1];
		cmyk.y = color.m_values[2];
		cmyk.k = color.m_values[3];
	}
	else if (model == colorModelLab)
	{
		ScColorTransform trans = doc ? doc->stdLabToCMYKTrans : ScCore->defaultLabToCMYKTrans;
		double inC[3];
		inC[0] = color.m_L_val;
		inC[1] = color.m_a_val;
		inC[2] = color.m_b_val;
		quint16 outC[4];
		trans.apply(inC, outC, 1);
		cmyk.c = outC[0] / 65535.0;
		cmyk.m = outC[1] / 65535.0;
		cmyk.y = outC[2] / 65535.0;
		cmyk.k = outC[3] / 65535.0;
	}
}
Exemple #28
0
QColor ScColorEngine::getShadeColorProof(const ScColor& color, const ScribusDoc* doc, double level)
{
	QColor tmp;
	bool doGC = doc ? doc->Gamut : false;
	bool cmsUse = doc ? doc->HasCMS : false;
	bool softProof = doc ? doc->SoftProofing : false;

	if (color.getColorModel() == colorModelRGB)
	{
		RGBColorF rgb;
		rgb.r = color.m_values[0];
		rgb.g = color.m_values[1];
		rgb.b = color.m_values[2];
		getShadeColorRGB(color, doc, rgb, level);
		// Match 133x behavior for rgb grey until we are able to make rgb profiled output
		// (RGB greys map to cmyk greys)
		if ((cmsUse && softProof) && (rgb.r == rgb.g && rgb.g == rgb.b))
		{
			doGC = false;
			CMYKColorF cmyk;
			cmyk.c = cmyk.m = cmyk.y = 0;
			cmyk.k = 1.0 - rgb.g;
			tmp = getColorProof(cmyk, doc, color.isSpotColor(), doGC);
		}
		else
			tmp = getColorProof(rgb, doc, color.isSpotColor(), doGC);
	}
	else if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColorF cmyk;
		cmyk.c = color.m_values[0];
		cmyk.m = color.m_values[1];
		cmyk.y = color.m_values[2];
		cmyk.k = color.m_values[3];
		getShadeColorCMYK(color, doc, cmyk, level);
		tmp = getColorProof(cmyk, doc, color.isSpotColor(), doGC);
	}
	else if (color.getColorModel() == colorModelLab)
	{
		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];
		ScColorTransform trans  = doc ? doc->stdLabToScreenTrans : ScCore->defaultLabToRGBTrans;
		ScColorTransform transProof   = doc ? doc->stdProofLab   : ScCore->defaultLabToRGBTrans;
		ScColorTransform transProofGC = doc ? doc->stdProofLabGC : ScCore->defaultLabToRGBTrans;
		if (cmsUse && doc && doc->SoftProofing)
		{
			ScColorTransform xform = doGC ? transProofGC : transProof;
			xform.apply(inC, outC, 1);
			tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257);
		}
		else
		{
			trans.apply(inC, outC, 1);
			tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257);
		}
	}
	
	return tmp;
}
Exemple #29
0
CMYKChoose::CMYKChoose( QWidget* parent, ScribusDoc* doc, ScColor orig, QString name, ColorList *Colors, bool newCol  )
		: QDialog( parent ), CurrSwatch(doc)
{
	setModal(true);
	m_doc = doc;
	isNew = newCol;
	dynamic = true;
	Wsave = false;
	isHLC = false;
	EColors = Colors;
	CurrSwatch.clear();
	alertIcon = IconManager::instance()->loadPixmap("alert.png");
	imageA = QPixmap(50,50);
	imageA.fill( ScColorEngine::getDisplayColor(orig, m_doc) );
	if ( ScColorEngine::isOutOfGamut(orig, m_doc) )
		paintAlert(alertIcon,imageA, 2, 2, false);
	imageN = QPixmap(50,50);
	imageN.fill( ScColorEngine::getDisplayColor(orig, m_doc) );
	if ( ScColorEngine::isOutOfGamut(orig, m_doc) )
		paintAlert(alertIcon, imageN, 2, 2, false);
	Farbe = orig;

	resize( 498, 306 );
	setWindowTitle( tr( "Edit Color" ) );
	setWindowIcon(IconManager::instance()->loadIcon("AppIcon.png"));

	setupUi(this);
	ColorMap->setDoc(doc);

	ColorName->setText( name );
	ComboBox1->addItem( tr( "CMYK" ) );
	ComboBox1->addItem( tr( "RGB" ) );
	ComboBox1->addItem( tr( "Web Safe RGB" ) );
	ComboBox1->addItem( tr( "Lab" ) );
	ComboBox1->addItem( tr( "HLC" ) );

	Separations->setChecked(orig.isSpotColor());

	OldC->setPixmap( imageA );
	NewC->setPixmap( imageN );

	buttonOK->setText(CommonStrings::tr_OK);
	buttonOK->setDefault( true );
	buttonCancel->setText(CommonStrings::tr_Cancel);

	hsvSelector = Swatches->addTopLevelItem( tr( "HSV Color Map" ) );
	hsvSelector->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
	csm.findPaletteLocations();
	systemSwatches = Swatches->addTopLevelItem( tr("Scribus Swatches"));
	csm.findPalettes(systemSwatches);
	Swatches->addSubItem("Scribus Small", systemSwatches);
	systemSwatches->setExpanded(true);
	userSwatches = Swatches->addTopLevelItem( tr("User Swatches"));
	csm.findUserPalettes(userSwatches);
	customColSet = csm.userPaletteNames();
	userSwatches->setExpanded(true);
	// Swatches combo uses elided text strings, so we cannot
	// set default combo item in constructor: at that point
	// the swatch combo widget does not know its width yet.
	// We set it in the dialog showEvent().
	// Swatches->setCurrentComboItem( tr( "HSV Color Map" ));

	slidersLayout->setSpacing(5);
	slidersLayout->setMargin(0);

	CyanSp->setNewUnit(0);
	CyanSp->setMinimum(0);
	CyanSp->setMaximum(100);
	CyanSp->setSuffix( tr(" %"));

	CyanSL->setAutoFillBackground(true);
	CyanSL->setMinimumSize(QSize(255, 16));
	CyanSL->setMinimum(0);
	CyanSL->setMaximum(100);
	CyanSL->setPalette(sliderPix(180));

	MagentaSp->setNewUnit(0);
	MagentaSp->setMinimum(0);
	MagentaSp->setMaximum(100);
	MagentaSp->setSuffix( tr(" %"));

	MagentaSL->setAutoFillBackground(true);
	MagentaSL->setMinimumSize(QSize(255, 16));
	MagentaSL->setMinimum(0);
	MagentaSL->setMaximum(100);
	MagentaSL->setPalette(sliderPix(300));

	YellowSp->setNewUnit(0);
	YellowSp->setMinimum(0);
	YellowSp->setMaximum(100);
	YellowSp->setSuffix( tr(" %"));

	YellowSL->setAutoFillBackground(true);
	YellowSL->setMinimumSize(QSize(255, 16));
	YellowSL->setMinimum(0);
	YellowSL->setMaximum(100);
	YellowSL->setPalette(sliderPix(60));

	BlackSp->setNewUnit(0);
	BlackSp->setMinimum(0);
	BlackSp->setMaximum(100);
	BlackSp->setSuffix( tr(" %"));

	BlackSL->setAutoFillBackground(true);
	BlackSL->setMinimumSize(QSize(255, 16));
	BlackSL->setMinimum(0);
	BlackSL->setMaximum(100);
	BlackSL->setPalette(sliderBlack());

	if (orig.getColorModel () == colorModelCMYK)
	{
		double ccd, cmd, cyd, ckd;
		CMYKColor cmyk;
		ScColorEngine::getCMYKValues(orig, m_doc, cmyk);
		ccd = cmyk.c / 2.55;
		cmd = cmyk.m / 2.55;
		cyd = cmyk.y / 2.55;
		ckd = cmyk.k / 2.55;
		CyanSp->setValue(ccd);
		CyanSL->setValue(qRound(ccd * 1000));
		MagentaSp->setValue(cmd);
		MagentaSL->setValue(qRound(cmd * 1000));
		YellowSp->setValue(cyd);
		YellowSL->setValue(qRound(cyd * 1000));
		BlackSp->setValue(ckd);
		BlackSL->setValue(qRound(ckd * 1000));
		BlackComp = cmyk.k;
	}
	int h, s, v;
	ScColorEngine::getRGBColor(orig, m_doc).getHsv(&h, &s, &v);
	ColorMap->setFixedWidth(180);
	ColorMap->drawPalette(v);
	ColorMap->setMark(h, s);
	Fnam = name;
	ColorName->selectAll();
	ColorName->setFocus();
	TabStack->setCurrentIndex(0);
	setFixedSize(minimumSizeHint());
	setContextMenuPolicy(Qt::CustomContextMenu);
	if (orig.getColorModel () == colorModelRGB)
	{
		ComboBox1->setCurrentIndex(1);
		selModel ( tr( "RGB" ));
	}
	else if (orig.getColorModel() == colorModelCMYK)
	{
		ComboBox1->setCurrentIndex(0);
		selModel ( tr( "CMYK" ));
	}
	else if (orig.getColorModel() == colorModelLab)
	{
		ComboBox1->setCurrentIndex(3);
		selModel ( tr( "Lab" ));
	}
	isRegistration = Farbe.isRegistrationColor();
	if (Farbe.isRegistrationColor())
	{
		ComboBox1->setEnabled(false);
		Separations->setEnabled(false);
	}
	// signals and slots connections
//	Regist->setToolTip( "<qt>" + tr( "Choosing this will enable printing this on all plates. Registration colors are used for printer marks such as crop marks, registration marks and the like. These are not typically used in the layout itself." ) + "</qt>");
	Separations->setToolTip( "<qt>" + tr( "Choosing this will make this color a spot color, thus creating another spot when creating plates or separations. This is used most often when a logo or other color needs exact representation or cannot be replicated with CMYK inks. Metallic and fluorescent inks are good examples which cannot be easily replicated with CMYK inks." ) + "</qt>");
	connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( buttonOK, SIGNAL( clicked() ), this, SLOT( leave() ) );
	connect( CyanSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
	connect( MagentaSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
	connect( YellowSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
	connect( BlackSp, SIGNAL( valueChanged(double) ), this, SLOT( setValSLiders(double) ) );
	connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setValueS(int) ) );
	connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setValueS(int) ) );
	connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setValueS(int) ) );
	connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setValueS(int) ) );
	connect( CyanSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
	connect( MagentaSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
	connect( YellowSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
	connect( BlackSL, SIGNAL( valueChanged(int) ), this, SLOT( setColor() ) );
	connect( ColorMap, SIGNAL( ColorVal(int, int, bool)), this, SLOT( setColor2(int, int, bool)));
	connect( ComboBox1, SIGNAL(activated(const QString&)), this, SLOT(selModel(const QString&)));
//	connect( Swatches, SIGNAL(activated(int)), this, SLOT(selSwatch(int)));
	connect(Swatches, SIGNAL(activated(const QString &)), this, SLOT(selSwatch()));
	connect(ColorSwatch, SIGNAL( itemClicked(QListWidgetItem*) ), this, SLOT( selFromSwatch(QListWidgetItem*) ) );
	connect(Separations, SIGNAL(clicked()), this, SLOT(setSpot()));
//	connect(Regist, SIGNAL(clicked()), this, SLOT(setRegist()));
	connect(this, SIGNAL(customContextMenuRequested (const QPoint &)), this, SLOT(slotRightClick()));
	layout()->activate();
}
Exemple #30
0
QColor ScColorEngine::getDisplayColor(const ScColor& color, const ScribusDoc* doc)
{
	QColor tmp;
	if (color.getColorModel() == colorModelRGB)
	{
		RGBColorF rgb;
		rgb.r = color.m_values[0];
		rgb.g = color.m_values[1];
		rgb.b = color.m_values[2];
		tmp = getDisplayColor(rgb, doc, color.isSpotColor());
	}
	else if (color.getColorModel() == colorModelCMYK)
	{
		CMYKColorF cmyk;
		cmyk.c = color.m_values[0];
		cmyk.m = color.m_values[1];
		cmyk.y = color.m_values[2];
		cmyk.k = color.m_values[3];
		tmp = getDisplayColor(cmyk, doc, color.isSpotColor());
	}
	else if (color.getColorModel() == colorModelLab)
	{
		bool cmsUse = doc ? doc->HasCMS : false;
		ScColorTransform trans  = doc ? doc->stdLabToScreenTrans : ScCore->defaultLabToRGBTrans;
		if (cmsUse && trans)
		{
			double inC[3];
			inC[0] = color.m_L_val;
			inC[1] = color.m_a_val;
			inC[2] = color.m_b_val;
			quint16 outC[3];
			trans.apply(inC, outC, 1);
			tmp = QColor(outC[0] / 257, outC[1] / 257, outC[2] / 257);
		}
		else
		{
			// First step: Lab -> XYZ
			double var_Y = (color.m_L_val + 16) / 116.0;
			double var_X = color.m_a_val / 500.0 + var_Y;
			double var_Z = var_Y - color.m_b_val / 200.0;
			if (pow(var_Y, 3) > 0.008856)
				var_Y = pow(var_Y, 3);
			else
				var_Y = (var_Y - 16.0 / 116.0) / 7.787;
			if (pow(var_X, 3) > 0.008856)
				var_X = pow(var_X, 3);
			else
				var_X = (var_X - 16.0 / 116.0) / 7.787;
			if (pow(var_Z, 3) > 0.008856)
				var_Z = pow(var_Z, 3);
			else
				var_Z = (var_Z - 16.0 / 116.0) / 7.787;
			// Second step: XYZ -> RGB
			// Whitepoint D50
			var_X = 0.990720 * var_X;
			var_Y = 1.00000  * var_Y;
			var_Z = 0.825210 * var_Z;
			double var_R = var_X *  3.2406 + var_Y * -1.5372 + var_Z * -0.4986;
			double var_G = var_X * -0.9689 + var_Y *  1.8758 + var_Z *  0.0415;
			double var_B = var_X *  0.0557 + var_Y * -0.2040 + var_Z *  1.0570;
			if (var_R > 0.0031308)
				var_R = 1.055 * (pow(var_R, (1.0 / 2.4))) - 0.055;
			else
				var_R = 12.92 * var_R;
			if (var_G > 0.0031308)
				var_G = 1.055 * (pow(var_G, (1.0 / 2.4))) - 0.055;
			else
				var_G = 12.92 * var_G;
			if (var_B > 0.0031308)
				var_B = 1.055 * (pow(var_B, (1.0 / 2.4))) - 0.055;
			else
				var_B = 12.92 * var_B;
			tmp = QColor(0, 0, 0, 0);
			var_R = qMax(qMin(var_R, 1.0), 0.0);
			var_G = qMax(qMin(var_G, 1.0), 0.0);
			var_B = qMax(qMin(var_B, 1.0), 0.0);
			tmp.setRgbF(var_R, var_G, var_B);
		}
	}
	return tmp;
}