当前位置: 首页>>代码示例>>C++>>正文


C++ ScColor::setLabColor方法代码示例

本文整理汇总了C++中ScColor::setLabColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ScColor::setLabColor方法的具体用法?C++ ScColor::setLabColor怎么用?C++ ScColor::setLabColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScColor的用法示例。


在下文中一共展示了ScColor::setLabColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: convertToModel

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;
}
开发者ID:luzpaz,项目名称:scribus,代码行数:51,代码来源:sccolorengine.cpp

示例2: importFile

bool PaletteLoader_Swatchbook::importFile(const QString& fileName, bool /*merge*/)
{
	ScColor lf;
	int oldCount = m_colors->count();
	
	QScopedPointer<ScZipHandler> uz(new ScZipHandler());
	if (!uz->open(fileName))
		return false;
	if (!uz->contains("swatchbook.xml"))
		return false;
	
	QByteArray docBytes;
	if (!uz->read("swatchbook.xml", docBytes))
		return false;

	QString docText = QString::fromUtf8(docBytes);
	QDomDocument docu("scridoc");
	if (!docu.setContent(docText))
		return false;
	
	QDomElement docElem = docu.documentElement();
	for (QDomElement drawPag = docElem.firstChildElement(); !drawPag.isNull(); drawPag = drawPag.nextSiblingElement())
	{
		if (drawPag.tagName() == "materials")
		{
			for (QDomElement spf = drawPag.firstChildElement(); !spf.isNull(); spf = spf.nextSiblingElement() )
			{
				if (spf.tagName() == "color")
				{
					bool isSpot = spf.attribute("usage") == "spot";
					QString colorName = "";
					ScColor tmp;
					tmp.setRegistrationColor(false);
					for (QDomElement spp = spf.firstChildElement(); !spp.isNull(); spp = spp.nextSiblingElement() )
					{
						if (spp.tagName() == "metadata")
						{
							for (QDomElement spm = spp.firstChildElement(); !spm.isNull(); spm = spm.nextSiblingElement() )
							{
								if (spm.tagName() == "dc:identifier")
									colorName = spm.text();
							}
						}
						else if (spp.tagName() == "values")
						{
							QString colorVals = spp.text();
							ScTextStream CoE(&colorVals, QIODevice::ReadOnly);
							if (spp.attribute("model") == "Lab")
							{
								double inC[3];
								CoE >> inC[0];
								CoE >> inC[1];
								CoE >> inC[2];
								tmp.setLabColor(inC[0], inC[1], inC[2]);
								tmp.setSpotColor(isSpot);
							}
							else if (spp.attribute("model") == "CMYK")
							{
								double c, m, y, k;
								CoE >> c >> m >> y >> k;
								tmp.setColorF(c, m, y, k);
								tmp.setSpotColor(isSpot);
							}
							else if (spp.attribute("model") == "RGB")
							{
								double r, g, b;
								CoE >> r >> g >> b;
								tmp.setRgbColorF(r, g, b);
								tmp.setSpotColor(false);
							}
开发者ID:luzpaz,项目名称:scribus,代码行数:70,代码来源:paletteloader_swatchbook.cpp

示例3: importColorsFromFile


//.........这里部分代码省略.........
					QString dTag = "";
					dTag = elem.tagName();
					QString nameMask = "%1";
					nameMask = elem.attribute("mask", "%1");
					QDomNode PAGE = elem.firstChild();
					while (!PAGE.isNull())
					{
						QDomElement pg = PAGE.toElement();
						if (pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
						{
							if (pg.hasAttribute("SPACE"))
							{
								QString space = pg.attribute("SPACE");
								if (space == "CMYK")
								{
									double c = pg.attribute("C", "0").toDouble() / 100.0;
									double m = pg.attribute("M", "0").toDouble() / 100.0;
									double y = pg.attribute("Y", "0").toDouble() / 100.0;
									double k = pg.attribute("K", "0").toDouble() / 100.0;
									lf.setCmykColorF(c, m, y, k);
								}
								else if (space == "RGB")
								{
									double r = pg.attribute("R", "0").toDouble() / 255.0;
									double g = pg.attribute("G", "0").toDouble() / 255.0;
									double b = pg.attribute("B", "0").toDouble() / 255.0;
									lf.setRgbColorF(r, g, b);
								}
								else if (space == "Lab")
								{
									double L = pg.attribute("L", "0").toDouble();
									double a = pg.attribute("A", "0").toDouble();
									double b = pg.attribute("B", "0").toDouble();
									lf.setLabColor(L, a, b);
								}
							}
							else if (pg.hasAttribute("CMYK"))
								lf.setNamedColor(pg.attribute("CMYK"));
							else if (pg.hasAttribute("RGB"))
								lf.fromQColor(QColor(pg.attribute("RGB")));
							else
							{
								double L = pg.attribute("L", "0").toDouble();
								double a = pg.attribute("A", "0").toDouble();
								double b = pg.attribute("B", "0").toDouble();
								lf.setLabColor(L, a, b);
							}
							if (pg.hasAttribute("Spot"))
								lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
							else
								lf.setSpotColor(false);
							if (pg.hasAttribute("Register"))
								lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
							else
								lf.setRegistrationColor(false);
							EditColors.tryAddColor(pg.attribute("NAME"), lf);
						}
						else if (pg.tagName() == "Gradient")
						{
							if (dialogGradients != NULL)
							{
								VGradient gra = VGradient(VGradient::linear);
								gra.clearStops();
								QDomNode grad = pg.firstChild();
								while (!grad.isNull())
								{
开发者ID:HOST-Oman,项目名称:scribus,代码行数:67,代码来源:util_color.cpp


注:本文中的ScColor::setLabColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。