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


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

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


在下文中一共展示了ScColor::setColorRGB方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
	{
		RGBColor rgb;
		getRGBValues(color, doc, rgb);
		newCol.setColorRGB(rgb.r, rgb.g, rgb.b);
	}
	else if (model == colorModelCMYK)
	{
		CMYKColor cmyk;
		getCMYKValues(color, doc, cmyk);
		newCol.setColor(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] = color.CR * 257;
			inC[1] = color.MG * 257;
			inC[2] = color.YB * 257;
			trans.apply(inC, outC, 1);
			newCol.setColor(outC[0], outC[1], outC[2]);
		}
		else
		{
			ScColorProfile profRGB = doc ? doc->DocInputCMYKProf : ScCore->defaultCMYKProfile;
			ScColorProfile profLab = ScCore->defaultLabProfile;
			ScColorTransform trans = engine.createTransform(profRGB, Format_CMYK_16, profLab, Format_Lab_Dbl, Intent_Perceptual, 0);
			double outC[3];
			unsigned short inC[4];
			inC[0] = color.CR * 257;
			inC[1] = color.MG * 257;
			inC[2] = color.YB * 257;
			inC[3] = color.K * 257;
			trans.apply(inC, outC, 1);
			newCol.setColor(outC[0], outC[1], outC[2]);
		}
	}
	return newCol;
}
开发者ID:WOF-Softwares,项目名称:ScribusCTL,代码行数:51,代码来源:sccolorengine.cpp

示例2: defColor

void XtgScanner::defColor()
{
	bool isSpot = false;
	ScColor tmp;
	enterState(stringMode);
	token = getToken();
	while (lookAhead() != '>' )
	{
		token = getToken();
		if ((token == "CMJN") || (token == "CMYK"))
		{
			enterState(tagMode);
			token = getToken();
			if (token == "S")
			{
				token = getToken();
				isSpot = true;
			}
			double c = getToken().toDouble();
			double m = getToken().toDouble();
			double y = getToken().toDouble();
			double k = getToken().toDouble();
			tmp.setColor(qRound(c * 2.55), qRound(m * 255), qRound(y * 255), qRound(k * 255));
			tmp.setSpotColor(isSpot);
			tmp.setRegistrationColor(false);
			doc->PageColors.tryAddColor(sfcName, tmp);
		}
		else if (token == "RGB")
		{
			enterState(tagMode);
			token = getToken();
			if (token == "S")
			{
				token = getToken();
				isSpot = true;
			}
			double r = getToken().toDouble();
			double g = getToken().toDouble();
			double b = getToken().toDouble();
			tmp.setColorRGB(qRound(r * 2.55), qRound(g * 255), qRound(b * 255));
			tmp.setSpotColor(isSpot);
			tmp.setRegistrationColor(false);
			doc->PageColors.tryAddColor(sfcName, tmp);
		}
	}
	top++;
	enterState(textMode);
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:48,代码来源:xtgscanner.cpp

示例3: 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 )
	{
		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;
}
开发者ID:JLuc,项目名称:scribus,代码行数:20,代码来源:sccolorengine.cpp

示例4: if

CWDialog::CWDialog(QWidget* parent, ScribusDoc* doc, const char* name, bool modal)
	: QDialog (parent),
	  m_Doc(doc)
{
	setupUi(this);
	setObjectName(name);
	setModal(modal);
	int h, s, v;
	ScColor color;
	QString colorName;
	connectSlots(false);
	// setup combobox
	typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Monochromatic), colorWheel->Monochromatic);
	typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Analogous), colorWheel->Analogous);
	typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Complementary), colorWheel->Complementary);
	typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Split), colorWheel->Split);
	typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Triadic), colorWheel->Triadic);
	typeCombo->addItem(colorWheel->getTypeDescription(colorWheel->Tetradic), colorWheel->Tetradic);
	// defects
	defectCombo->addItem(CommonStrings::trVisionNormal);
	defectCombo->addItem(CommonStrings::trVisionProtanopia);
	defectCombo->addItem(CommonStrings::trVisionDeuteranopia);
	defectCombo->addItem(CommonStrings::trVisionTritanopia);
	defectCombo->addItem(CommonStrings::trVisionFullColorBlind);
	// document colors
	documentColorList->updateBox(m_Doc->PageColors, ColorListBox::fancyPixmap);
	// preferences
	prefs = PrefsManager::instance()->prefsFile->getPluginContext("colorwheel");
	typeCombo->setCurrentIndex(prefs->getInt("cw_type", 0));
	angleSpin->setValue(prefs->getInt("cw_angle", 15));
	colorWheel->currentDoc = m_Doc;
	colorWheel->angle = angleSpin->value();
	colorWheel->baseAngle = prefs->getInt("cw_baseangle", 0);
	colorspaceTab->setCurrentIndex(prefs->getInt("cw_space", 0));
	color.setNamedColor(prefs->get("cw_color", "#00000000"));
	// Handle color previously selected in the document tab
	if (colorspaceTab->currentWidget() == tabDocument)
	{
		colorName = prefs->get("cw_colorname", "");
		if (!colorName.isEmpty() && m_Doc->PageColors.contains(colorName))
			color = m_Doc->PageColors[colorName];
		else
			color.setColorRGB(0, 0, 0); //Trigger use of defaults
	}
	// Handle achromatic colors
	QColor rgb = ScColorEngine::getRGBColor(color, m_Doc);
	rgb.getHsv(&h, &s, &v);
	if (h == -1)
	{   // Reset to defaults
		colorWheel->baseAngle = 0;
		colorWheel->currentColorSpace = colorModelCMYK;
		colorWheel->actualColor = colorWheel->colorByAngle(0);
		colorspaceTab->setCurrentIndex(0);
	}
	else if (colorspaceTab->currentWidget() == tabDocument)
	{
		colorWheel->actualColor = color;
		QList<QListWidgetItem*> results = documentColorList->findItems(colorName, Qt::MatchFixedString|Qt::MatchCaseSensitive);
		if (results.count() > 0)
			documentColorList->setCurrentItem(results[0]);
	}
	else
		colorWheel->actualColor = color;

	resize(QSize(prefs->getInt("cw_width", 640),
		   prefs->getInt("cw_height", 480)).expandedTo(minimumSizeHint()));
	previewLabel->resize(prefs->getInt("cw_samplex", 300), prefs->getInt("cw_sampley", 100));
		
	// setup
	colorspaceTab_currentChanged(colorspaceTab->currentIndex());

	// signals and slots that cannot be in ui file
	connect(colorWheel, SIGNAL(clicked(int, const QPoint&)),
			this, SLOT(colorWheel_clicked(int, const QPoint&)));
	connect(documentColorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
			this, SLOT(documentColorList_currentChanged(QListWidgetItem *)));
	connect(colorList, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
			this, SLOT(colorList_currentChanged(QListWidgetItem *)));
	connect(angleSpin, SIGNAL(valueChanged(int)),
			this, SLOT(angleSpin_valueChanged(int)));
	connect(colorspaceTab, SIGNAL(currentChanged(int)),
			this, SLOT(colorspaceTab_currentChanged(int)));
	connect(typeCombo, SIGNAL(activated(int)), this, SLOT(typeCombo_activated(int)));
	connect(defectCombo, SIGNAL(activated(int)), this, SLOT(defectCombo_activated(int)));
	connect(addButton, SIGNAL(clicked()), this, SLOT(addButton_clicked()));
	connect(replaceButton, SIGNAL(clicked()), this, SLOT(replaceButton_clicked()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelButton_clicked()));

	connectSlots(true);
}
开发者ID:Fahad-Alsaidi,项目名称:scribus,代码行数:90,代码来源:cwdialog.cpp

示例5: setColor

void CMYKChoose::setColor()
{
	int c, m, y;
	int h, s, v;
	int k = 0;
	double L, a, b;
	ScColor tmp;
	if (Farbe.getColorModel() == colorModelCMYK)
	{
		c = qRound(CyanSp->value() * 2.55);
		m = qRound(MagentaSp->value() * 2.55);
		y = qRound(YellowSp->value() * 2.55);
		k = qRound(BlackSp->value() * 2.55);
		tmp.setColor(c, m, y, k);
		Farbe = tmp;
		if (dynamic)
		{
			CyanSL->setPalette(sliderPix(180));
			MagentaSL->setPalette(sliderPix(300));
			YellowSL->setPalette(sliderPix(60));
			BlackSL->setPalette(sliderBlack());
		}
		BlackComp = k;
		ScColorEngine::getRGBColor(tmp, m_doc).getHsv(&h, &s, &v);
		ColorMap->drawPalette(v);
		ColorMap->setMark(h, s);
	}
	else if (Farbe.getColorModel() == colorModelRGB)
	{
		c = qRound(CyanSp->value());
		m = qRound(MagentaSp->value());
		y = qRound(YellowSp->value());
		k = qRound(BlackSp->value());
		if (Wsave)
		{
			blockSignals(true);
			c = c / 51 * 51;
			m = m / 51 * 51;
			y = y / 51 * 51;
			CyanSp->setValue(c);
			MagentaSp->setValue(m);
			YellowSp->setValue(y);
			CyanSL->setValue(c * 1000.0);
			MagentaSL->setValue(m * 1000.0);
			YellowSL->setValue(y * 1000.0);
			blockSignals(false);
		}
		tmp.setColorRGB(c, m, y);
		QColor tmp2 = QColor(c, m, y);
		tmp2.getHsv(&h, &s, &v);
		BlackComp = 255 - v;
		Farbe = tmp;
		if (dynamic)
		{
			CyanSL->setPalette(sliderPix(0));
			MagentaSL->setPalette(sliderPix(120));
			YellowSL->setPalette(sliderPix(240));
		}
		BlackComp = k;
		ScColorEngine::getRGBColor(tmp, m_doc).getHsv(&h, &s, &v);
		ColorMap->drawPalette(v);
		ColorMap->setMark(h, s);
	}
	else if (Farbe.getColorModel() == colorModelLab)
	{
		double Lalt;
		Farbe.getLab(&Lalt, &a, &b);
		if (isHLC)
		{
			L = MagentaSp->value();
			double cv = 360 - CyanSp->value();
			double yv = YellowSp->value();
			QLineF lin = QLineF::fromPolar(yv, cv);
			a = lin.p2().x();
			b = lin.p2().y();
		}
		else
		{
			L = CyanSp->value();
			a = MagentaSp->value();
			b = YellowSp->value();
		}
		tmp.setColor(L, a, b);
		Farbe = tmp;
		if (dynamic)
		{
			CyanSL->setPalette(sliderPix(0));
			MagentaSL->setPalette(sliderPix(120));
			YellowSL->setPalette(sliderPix(240));
		}
		BlackComp = qRound(L * 2.55);
		if (L != Lalt)
			ColorMap->drawPalette(L * 2.55);
		ColorMap->setMark(a, b);
	}
	imageN.fill(ScColorEngine::getDisplayColor(tmp, m_doc) );
	if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
		paintAlert(alertIcon, imageN, 2, 2, false);
	NewC->setPixmap( imageN );
}
开发者ID:gyuris,项目名称:scribus,代码行数:100,代码来源:cmykfw.cpp

示例6: initialiseDefaultPrefs

void ColorSetManager::initialiseDefaultPrefs(struct ApplicationPrefs& appPrefs)
{
	QString defaultSwatch = ScPaths::instance().shareDir() + "swatches/" + "Scribus_Basic.xml";
	QFile fiC(defaultSwatch);
	if (!fiC.exists())
	{
		appPrefs.colorPrefs.DColors.insert("White", ScColor(0, 0, 0, 0));
		appPrefs.colorPrefs.DColors.insert("Black", ScColor(0, 0, 0, 255));
		ScColor cc = ScColor(255, 255, 255, 255);
		cc.setRegistrationColor(true);
		appPrefs.colorPrefs.DColors.insert("Registration", cc);
		appPrefs.colorPrefs.DColors.insert("Blue", ScColor(255, 255, 0, 0));
		appPrefs.colorPrefs.DColors.insert("Cyan", ScColor(255, 0, 0, 0));
		appPrefs.colorPrefs.DColors.insert("Green", ScColor(255, 0, 255, 0));
		appPrefs.colorPrefs.DColors.insert("Red", ScColor(0, 255, 255, 0));
		appPrefs.colorPrefs.DColors.insert("Yellow", ScColor(0, 0, 255, 0));
		appPrefs.colorPrefs.DColors.insert("Magenta", ScColor(0, 255, 0, 0));
		appPrefs.colorPrefs.DColorSet = "Scribus_Small";
	}
	else
	{
		if (fiC.open(QIODevice::ReadOnly))
		{
			QString ColorEn, Cname;
			int Rval, Gval, Bval;
			QTextStream tsC(&fiC);
			ColorEn = tsC.readLine();
			if (ColorEn.startsWith("<?xml version="))
			{
				QByteArray docBytes("");
				loadRawText(defaultSwatch, docBytes);
				QString docText("");
				docText = QString::fromUtf8(docBytes);
				QDomDocument docu("scridoc");
				docu.setContent(docText);
				ScColor lf = ScColor();
				QDomElement elem = docu.documentElement();
				QDomNode PAGE = elem.firstChild();
				while(!PAGE.isNull())
				{
					QDomElement pg = PAGE.toElement();
					if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
					{
						if (pg.hasAttribute("CMYK"))
							lf.setNamedColor(pg.attribute("CMYK"));
						else
							lf.fromQColor(QColor(pg.attribute("RGB")));
						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);
						appPrefs.colorPrefs.DColors.insert(pg.attribute("NAME"), lf);
					}
					PAGE=PAGE.nextSibling();
				}
			}
			else
			{
				while (!tsC.atEnd())
				{
					ColorEn = tsC.readLine();
					QTextStream CoE(&ColorEn, QIODevice::ReadOnly);
					CoE >> Rval;
					CoE >> Gval;
					CoE >> Bval;
					CoE >> Cname;
					ScColor tmp;
					tmp.setColorRGB(Rval, Gval, Bval);
					appPrefs.colorPrefs.DColors.insert(Cname, tmp);
				}
			}
			fiC.close();
		}
		appPrefs.colorPrefs.DColorSet = ScPaths::instance().shareDir() + "swatches/" + "Scribus Basic";
	}
开发者ID:JLuc,项目名称:scribus,代码行数:79,代码来源:colorsetmanager.cpp


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