本文整理汇总了C++中QColor::setCmyk方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setCmyk方法的具体用法?C++ QColor::setCmyk怎么用?C++ QColor::setCmyk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setCmyk方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toColor
QColor ColorRangeBase::toColor(const QVariant &v, ColorRangeBase::ColorModel colormodel)
{
if ( v.type() == QVariant::Color)
return QColor(v.value<QColor>());
else if ( v.type() == QVariant::String){
QRegExp separ("[(]|,|[)]");
QStringList parts = (v.toString()).split(separ);
if(parts.last().isEmpty())
parts.removeLast();
QColor clr;
bool ok1,ok2,ok3,ok4,ok5 =true;
if ( parts.size() >= 5){
double component1 = parts[1].toDouble(&ok1);
double component2 = parts[2].toDouble(&ok2);
double component3 = parts[3].toDouble(&ok3);
double component4 = parts[4].toDouble(&ok4);
double component5 = parts.size()== 6 ? parts[5].toDouble(&ok5) : rUNDEF;
if(! (ok1 && ok2 && ok3 && ok4 && ok5))
return QColor();
bool isFractional = component1 <= 1 && component2 <= 1 && component3 <= 1 && component4 <= 1;
if ( parts[0].toLower() == "rgba"){
if ( isFractional){
clr.setRgbF(component1,component2, component3);
clr.setAlphaF(component4);
}
else{
clr.setRgb(component1,component2, component3);
clr.setAlpha(component4);
}
}else if ( parts[0].toLower() == "hsla"){
if ( isFractional){
clr.setHslF(component1,component2, component3);
clr.setAlphaF(component4);
}
else{
clr.setHsl(component1,component2, component3);
clr.setAlpha(component4);
}
} else if ( parts[0].toLower() == "cmyka" && parts.size() == 6){
if ( isFractional){
clr.setCmykF(component1,component2, component3, component4);
clr.setAlphaF(component5);
}
else{
clr.setCmyk(component1,component2, component3, component4);
clr.setAlpha(component5);
}
}
return clr;
}
} else if( v.type() == QVariant::ULongLong){
return ColorRangeBase::toColor(v.toULongLong(),colormodel);
} else if( v.type() == QVariant::Double){
return ColorRangeBase::toColor(v.toULongLong(),colormodel);
}
return QColor();
}
示例2: handlePaletteCase
bool RasterCoverageConnector::handlePaletteCase(Size<> &rastersize, RasterCoverage* raster) {
auto layerHandle = gdal()->getRasterBand(_handle->handle(), 1);
auto paletteHandle = gdal()->getColorPalette(layerHandle);
ColorPalette *palette = new ColorPalette();
if (!paletteHandle)
return false;
int count = gdal()->getColorPaletteSize(paletteHandle);
if ( count == 0)
return false;
ColorRangeBase::ColorModel model;
GDALPaletteInterp colorType = gdal()->getPaletteColorInterpretation(paletteHandle);
for(int i = 0; i < count; ++i) {
GDALColorEntry *entry = gdal()->getColorPaletteEntry(paletteHandle, i);
if ( !entry)
continue;
QColor clr;
switch ( colorType){
case GPI_RGB:
clr.setRgb(entry->c1, entry->c2, entry->c3);
model = ColorRangeBase::cmRGBA;
break;
case GPI_HLS:
clr.setHsl(entry->c1, entry->c2, entry->c3); break;
model = ColorRangeBase::cmHSLA;
break;
case GPI_CMYK:
clr.setCmyk(entry->c1, entry->c2, entry->c3, entry->c4);
model = ColorRangeBase::cmCYMKA;
break;
case GPI_Gray:
clr.setRgb(entry->c1, entry->c1, entry->c1);
model = ColorRangeBase::cmGREYSCALE;
}
clr.setAlpha(entry->c4);
palette->add(new ColorItem(clr));
}
palette->defaultColorModel(model);
_typeSize = 1;
_gdalValueType = gdal()->rasterDataType(layerHandle);
raster->datadefRef() = DataDefinition(IDomain("colorpalette"), reinterpret_cast<Range *>(palette));
return true;
}
示例3: loadColor
void ColorRangeBase::loadColor(QColor& clr, QDataStream &stream){
int c1, c2, c3, c4;
stream >> c1 >> c2 >> c3 >> c4;
switch (defaultColorModel()){
case ColorRangeBase::cmRGBA:
clr.setRgb(c1,c2,c3);
clr.setAlpha(c4);
break;
case ColorRangeBase::cmHSLA:
clr.setHsl(c1,c2,c3);
clr.setAlpha(c4);
break;
case ColorRangeBase::cmCYMKA:
clr.setCmyk(c1,c2,c3, c4);
break;
case ColorRangeBase::cmGREYSCALE:
stream << clr.red();
default:
break;
}
}
示例4: setCmyk
void tst_QColor::setCmyk()
{
QColor color;
for (int A = 0; A <= USHRT_MAX; ++A) {
{
// 0-255
int a = A >> 8;
color.setCmyk(0, 0, 0, 0, a);
QCOMPARE(color.alpha(), a);
int c, m, y, k, a2;
color.getCmyk(&c, &m, &y, &k, &a2);
QCOMPARE(a2, a);
}
{
// 0.0-1.0
qreal a = A / qreal(USHRT_MAX);
color.setCmykF(0.0, 0.0, 0.0, 0.0, a);
QCOMPARE(color.alphaF(), a);
qreal c, m, y, k, a2;
color.getCmykF(&c, &m, &y, &k, &a2);
QCOMPARE(a2, a);
}
}
for (int C = 0; C <= USHRT_MAX; ++C) {
{
// 0-255
int c = C >> 8;
color.setCmyk(c, 0, 0, 0, 0);
QCOMPARE(color.cyan(), c);
int c2, m, y, k, a;
color.getCmyk(&c2, &m, &y, &k, &a);
QCOMPARE(c2, c);
}
{
// 0.0-1.0
qreal c = C / qreal(USHRT_MAX);
color.setCmykF(c, 0.0, 0.0, 0.0, 0.0);
QCOMPARE(color.cyanF(), c);
qreal c2, m, y, k, a;
color.getCmykF(&c2, &m, &y, &k, &a);
QCOMPARE(c2, c);
}
}
for (int M = 0; M <= USHRT_MAX; ++M) {
{
// 0-255
int m = M >> 8;
color.setCmyk(0, m, 0, 0, 0);
QCOMPARE(color.magenta(), m);
int c, m2, y, k, a;
color.getCmyk(&c, &m2, &y, &k, &a);
QCOMPARE(m2, m);
}
{
// 0.0-1.0
qreal m = M / qreal(USHRT_MAX);
color.setCmykF(0.0, m, 0.0, 0.0, 0.0);
QCOMPARE(color.magentaF(), m);
qreal c, m2, y, k, a;
color.getCmykF(&c, &m2, &y, &k, &a);
QCOMPARE(m2, m);
}
}
for (int Y = 0; Y <= USHRT_MAX; ++Y) {
{
// 0-255
int y = Y >> 8;
color.setCmyk(0, 0, y, 0, 0);
QCOMPARE(color.yellow(), y);
int c, m, y2, k, a;
color.getCmyk(&c, &m, &y2, &k, &a);
QCOMPARE(y2, y);
}
{
// 0.0-1.0
qreal y = Y / qreal(USHRT_MAX);
color.setCmykF(0.0, 0.0, y, 0.0, 0.0);
QCOMPARE(color.yellowF(), y);
qreal c, m, y2, k, a;
color.getCmykF(&c, &m, &y2, &k, &a);
QCOMPARE(y2, y);
}
}
//.........这里部分代码省略.........
示例5: change_param_by_type
QColor color_selector::change_param_by_type (QColor color, int value, color_single_selector_type type)
{
int h = 0, s, v, l, r, g, b, a, c, m, y, k;
switch (type)
{
case color_single_selector_type::HSV_SATURATION:
case color_single_selector_type::HSV_HUE:
case color_single_selector_type::HSV_VALUE:
case color_single_selector_type::HSV_ALPHA:
color.getHsv (&h, &s, &v, &a);
break;
case color_single_selector_type::HSL_HUE:
case color_single_selector_type::HSL_SATURATION:
case color_single_selector_type::HSL_LIGHTNESS:
case color_single_selector_type::HSL_ALPHA:
color.getHsl (&h, &s, &l, &a);
break;
case color_single_selector_type::RGB_RED:
case color_single_selector_type::RGB_GREEN:
case color_single_selector_type::RGB_BLUE:
case color_single_selector_type::RGB_ALPHA:
color.getRgb (&r, &g, &b, &a);
break;
case color_single_selector_type::CMYK_CYAN:
case color_single_selector_type::CMYK_MAGENTA:
case color_single_selector_type::CMYK_YELLOW:
case color_single_selector_type::CMYK_BLACK:
case color_single_selector_type::CMYK_ALPHA:
color.getCmyk (&c, &m, &y, &k, &a);
break;
}
if (value < 0)
value = 0;
if (value > get_param_maximum_by_type (type))
value = get_param_maximum_by_type (type);
if (h < 0)
h = 0;
switch (type)
{
case color_single_selector_type::HSL_HUE:
color.setHsl (value, s, l, a);
break;
case color_single_selector_type::HSV_HUE:
color.setHsv (value, s, v, a);
break;
case color_single_selector_type::HSL_LIGHTNESS:
color.setHsl (h, s, value, a);
break;
case color_single_selector_type::HSL_SATURATION:
color.setHsl (h, value, l, a);
break;
case color_single_selector_type::HSV_SATURATION:
color.setHsv (h, value, v, a);
break;
case color_single_selector_type::HSV_VALUE:
color.setHsv (h, s, value, a);
break;
case color_single_selector_type::RGB_RED:
color.setRgb (value, g, b, a);
break;
case color_single_selector_type::RGB_GREEN:
color.setRgb (r, value, b, a);
break;
case color_single_selector_type::RGB_BLUE:
color.setRgb (r, g, value, a);
break;
case color_single_selector_type::RGB_ALPHA:
color.setRgb (r, g, b, value);
break;
case color_single_selector_type::CMYK_CYAN:
color.setCmyk (value, m, y, k, a);
break;
case color_single_selector_type::CMYK_MAGENTA:
color.setCmyk (c, value, y, k, a);
break;
case color_single_selector_type::CMYK_YELLOW:
color.setCmyk (c, m, value, k, a);
break;
case color_single_selector_type::CMYK_BLACK:
color.setCmyk (c, m, y, value, a);
break;
case color_single_selector_type::HSL_ALPHA:
color.setHsl (h, s, l, value);
break;
case color_single_selector_type::HSV_ALPHA:
color.setHsv (h, s, v, value);
break;
case color_single_selector_type::CMYK_ALPHA:
color.setCmyk (c, m, y, k, value);
break;
}
return color;
}