本文整理汇总了C++中QColor::getCmyk方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::getCmyk方法的具体用法?C++ QColor::getCmyk怎么用?C++ QColor::getCmyk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::getCmyk方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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;
}
示例2: fromQColor
void ScColor::fromQColor(QColor color)
{
if (color.spec() == QColor::Cmyk)
{
int c, m, y, k;
color.getCmyk(&c, &m, &y, &k);
setColor(c, m, y, k);
}
else
{
int r, g, b;
color.getRgb(&r, &g, &b);
setColorRGB(r, g, b);
}
}
示例3: 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);
}
}
//.........这里部分代码省略.........
示例4: 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;
}