本文整理汇总了C++中KoColor类的典型用法代码示例。如果您正苦于以下问题:C++ KoColor类的具体用法?C++ KoColor怎么用?C++ KoColor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KoColor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QImage
QImage KisVisualColorSelectorShape::getImageMap()
{
//qDebug() << this << ">>>>>>>>> getImageMap()" << m_d->imagesNeedUpdate;
if (m_d->imagesNeedUpdate == true) {
m_d->gradient = QImage(width(), height(), QImage::Format_ARGB32);
m_d->gradient.fill(Qt::transparent);
// KoColor c = m_d->currentColor;
// Fill a buffer with the right kocolors
quint8 *data = new quint8[width() * height() * height()];
quint8 *dataPtr = data;
for (int y = 0; y < m_d->gradient.height(); y++) {
for (int x=0; x < m_d->gradient.width(); x++) {
QPointF newcoordinate = convertWidgetCoordinateToShapeCoordinate(QPoint(x, y));
KoColor c = convertShapeCoordinateToKoColor(newcoordinate);
memcpy(dataPtr, c.data(), m_d->currentColor.colorSpace()->pixelSize());
dataPtr += m_d->currentColor.colorSpace()->pixelSize();
}
}
// Convert the buffer to a qimage
if (m_d->displayRenderer) {
m_d->gradient = m_d->displayRenderer->convertToQImage(m_d->currentColor.colorSpace(), data, width(), height());
}
else {
m_d->gradient = m_d->currentColor.colorSpace()->convertToQImage(data, width(), height(), 0, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
}
delete[] data;
m_d->imagesNeedUpdate = false;
}
return m_d->gradient;
}
示例2: setConfiguration
void KisWdgIndexColors::setConfiguration(const KisPropertiesConfigurationSP config)
{
PaletteGeneratorConfig palCfg;
palCfg.fromByteArray(config->getProperty("paletteGen").toByteArray());
ui->luminanceSlider->setValue(config->getFloat("LFactor")*100);
ui->aSlider->setValue(config->getFloat("aFactor")*100);
ui->bSlider->setValue(config->getFloat("bFactor")*100);
ui->alphaStepsSpinBox->setValue(config->getInt("alphaSteps"));
ui->colorLimitCheck->setChecked(config->getBool("reduceColorsEnabled"));
ui->colorLimit->setEnabled(config->getBool("reduceColorsEnabled"));
ui->colorLimit->setValue(config->getInt("colorLimit"));
ui->diagCheck->setChecked(palCfg.diagonalGradients);
ui->inbetweenSpinBox->setValue(palCfg.inbetweenRampSteps);
for(int y = 0; y < 4; ++y)
for(int x = 0; x < 4; ++x)
{
m_colorSelectors[y][x].checkbox->setChecked(palCfg.colorsEnabled[y][x]);
m_colorSelectors[y][x].button->setEnabled(palCfg.colorsEnabled[y][x]);
KoColor c;
c.fromQColor(palCfg.colors[y][x]);
m_colorSelectors[y][x].button->setColor(c);
}
for(int y = 0; y < 3; ++y)
m_stepSpinners[y]->setValue(palCfg.gradientSteps[y]);
IndexColorPalette pal = palCfg.generate();
ui->colorCount->setText(QString::number(pal.numColors()));
}
示例3: darkenPixel
inline void HairyBrush::darkenPixel(int wx, int wy, const KoColor &color)
{
m_dabAccessor->moveTo(wx, wy);
if (m_dab->colorSpace()->opacityU8(m_dabAccessor->rawData()) < color.opacityU8()) {
memcpy(m_dabAccessor->rawData(), color.data(), m_pixelSize);
}
}
示例4: paintParticle
void HairyBrush::paintParticle(QPointF pos, const KoColor& color)
{
// opacity top left, right, bottom left, right
memcpy(m_color.data(), color.data(), m_pixelSize);
quint8 opacity = color.opacityU8();
int ipx = int (pos.x());
int ipy = int (pos.y());
qreal fx = pos.x() - ipx;
qreal fy = pos.y() - ipy;
quint8 btl = qRound((1.0 - fx) * (1.0 - fy) * opacity);
quint8 btr = qRound((fx) * (1.0 - fy) * opacity);
quint8 bbl = qRound((1.0 - fx) * (fy) * opacity);
quint8 bbr = qRound((fx) * (fy) * opacity);
m_color.setOpacity(btl);
plotPixel(ipx , ipy, m_color);
m_color.setOpacity(btr);
plotPixel(ipx + 1 , ipy, m_color);
m_color.setOpacity(bbl);
plotPixel(ipx , ipy + 1, m_color);
m_color.setOpacity(bbr);
plotPixel(ipx + 1 , ipy + 1, m_color);
}
示例5: mouseMoveEvent
void KisColorPatches::mouseMoveEvent(QMouseEvent *event)
{
event->ignore();
KisColorSelectorBase::mouseMoveEvent(event);
if(event->isAccepted())
return;
if (!(event->buttons() & Qt::LeftButton))
return;
if ((event->pos() - m_dragStartPos).manhattanLength()
< QApplication::startDragDistance())
return;
KoColor koColor;
if(!colorAt(m_dragStartPos, &koColor))
return;
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QColor color = koColor.toQColor();
mimeData->setColorData(color);
mimeData->setText(color.name());
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
event->accept();
}
示例6: saturationDepletion
void HairyBrush::saturationDepletion(Bristle * bristle, KoColor &bristleColor, qreal pressure, qreal inkDeplation)
{
qreal saturation;
if (m_properties->useWeights) {
// new weighted way (experiment)
saturation = (
(pressure * m_properties->pressureWeight) +
(bristle->length() * m_properties->bristleLengthWeight) +
(bristle->inkAmount() * m_properties->bristleInkAmountWeight) +
((1.0 - inkDeplation) * m_properties->inkDepletionWeight)) - 1.0;
}
else {
// old way of computing saturation
saturation = (
pressure *
bristle->length() *
bristle->inkAmount() *
(1.0 - inkDeplation)) - 1.0;
}
m_transfo->setParameter(m_transfo->parameterId("h"), 0.0);
m_transfo->setParameter(m_transfo->parameterId("v"), 0.0);
m_transfo->setParameter(m_saturationId, saturation);
m_transfo->setParameter(3, 1);//sets the type to
m_transfo->setParameter(4, false);//sets the colorize to none.
m_transfo->transform(bristleColor.data(), bristleColor.data() , 1);
}
示例7: setStops
void KoStopGradient::setStops(QList< KoGradientStop > stops)
{
m_stops.clear();
KoColor color;
Q_FOREACH (const KoGradientStop & stop, stops) {
color = stop.second;
color.convertTo(colorSpace());
m_stops.append(KoGradientStop(stop.first, color));
}
示例8: getColorFromConverter
QColor KisVisualColorSelectorShape::getColorFromConverter(KoColor c){
QColor col;
KoColor color = c;
if (m_d->displayRenderer) {
color.convertTo(m_d->displayRenderer->getPaintingColorSpace());
col = m_d->displayRenderer->toQColor(c);
} else {
col = c.toQColor();
}
return col;
}
示例9: setColorFromSibling
void KisVisualColorSelectorShape::setColorFromSibling(KoColor c)
{
//qDebug() << this << "setColorFromSibling";
if (c.colorSpace() != m_d->colorSpace) {
c.convertTo(m_d->colorSpace);
}
m_d->currentColor = c;
Q_EMIT sigNewColor(c);
m_d->imagesNeedUpdate = true;
update();
}
示例10: setColor
void KisVisualColorSelectorShape::setColor(KoColor c)
{
//qDebug() << this << "KisVisualColorSelectorShape::setColor";
if (c.colorSpace() != m_d->colorSpace) {
c.convertTo(m_d->colorSpace);
}
m_d->currentColor = c;
updateCursor();
m_d->imagesNeedUpdate = true;
update();
}
示例11: if
void KoStopGradient::colorAt(KoColor& dst, qreal t) const
{
if (! m_stops.count())
return;
if (t <= m_stops.first().first || m_stops.count() == 1) {
// we have only one stop or t is before the first stop
// -> use the color of the first stop
dst.fromKoColor(m_stops.first().second);
} else if (t >= m_stops.last().first) {
// t is after the last stop
// -> use the color of the last stop
dst.fromKoColor(m_stops.last().second);
} else {
// we have at least two color stops
// -> find the two stops which frame our t
QList<KoGradientStop>::const_iterator stop = m_stops.begin();
QList<KoGradientStop>::const_iterator lastStop = m_stops.end();
// we already checked the first stop, so we start at the second
for (++stop; stop != lastStop; ++stop) {
// we break at the stop which is just after our t
if (stop->first > t)
break;
}
if ( !(*buffer.colorSpace() == *colorSpace())) {
buffer = KoColor(colorSpace());
}
const KoGradientStop& leftStop = *(stop - 1);
const KoGradientStop& rightStop = *(stop);
const quint8 *colors[2];
colors[0] = leftStop.second.data();
colors[1] = rightStop.second.data();
qreal localT;
qreal stopDistance = rightStop.first - leftStop.first;
if (stopDistance < DBL_EPSILON) {
localT = 0.5;
} else {
localT = (t - leftStop.first) / stopDistance;
}
qint16 colorWeights[2];
colorWeights[0] = static_cast<quint8>((1.0 - localT) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
colorSpace()->mixColorsOp()->mixColors(colors, colorWeights, 2, buffer.data());
dst.fromKoColor(buffer);
}
}
示例12: mousePressEvent
void KisColorPatches::mousePressEvent(QMouseEvent *event)
{
KoColor koColor;
if(!colorAt(event->pos(), &koColor))
return;
KisColorSelectorBase::mousePressEvent(event);
if(event->isAccepted())
return;
updateColorPreview(koColor.toQColor());
if (event->button() == Qt::LeftButton)
m_dragStartPos = event->pos();
}
示例13: QComboBox
KisShadeSelectorLineComboBox::KisShadeSelectorLineComboBox(QWidget *parent) :
QComboBox(parent),
m_popup(new KisShadeSelectorLineComboBoxPopup(this)),
m_parentProxy(new KisColorSelectorBaseProxyNoop()),
m_currentLine(new KisShadeSelectorLine(0,0,0, m_parentProxy.data(), this))
{
QGridLayout* l = new QGridLayout(this);
l->addWidget(m_currentLine);
m_currentLine->setEnabled(false);
KoColor color;
color.fromQColor(QColor(190, 50, 50));
m_currentLine->setColor(color);
updateSettings();
}
示例14: pick
bool pick(KisPaintDeviceSP dev, const QPoint& pos, KoColor *color)
{
KIS_ASSERT(dev);
KoColor pickedColor;
dev->pixel(pos.x(), pos.y(), &pickedColor);
pickedColor.convertTo(dev->compositionSourceColorSpace());
bool validColorPicked =
pickedColor.opacityU8() != OPACITY_TRANSPARENT_U8;
if (validColorPicked) {
pickedColor.setOpacity(OPACITY_OPAQUE_U8);
*color = pickedColor;
}
return validColorPicked;
}
示例15: hsvComparison
/*compares c1 and c2 based on HSV.
c1 < c2, returns -1
c1 = c2, returns 0
c1 > c2, returns 1 */
int hsvComparison(const KoColor& c1, const KoColor& c2) {
QColor qc1 = c1.toQColor();
QColor qc2 = c2.toQColor();
if (qc1.hue() < qc2.hue()) return -1;
if (qc1.hue() > qc2.hue()) return 1;
// hue is the same, ok let's compare saturation
if (qc1.saturation() < qc2.saturation()) return -1;
if (qc1.saturation() > qc2.saturation()) return 1;
// oh, also saturation is same?
if (qc1.value() < qc2.value()) return -1;
if (qc1.value() > qc2.value()) return 1;
// user selected two similar colors
return 0;
}