ShadowRectsData(const QRect &applyRect, const psd_layer_effects_context *context, const psd_layer_effects_shadow_base *shadow, Direction direction) { spread_size = (shadow->spread() * shadow->size() + 50) / 100; blur_size = shadow->size() - spread_size; offset = shadow->calculateOffset(context); // need rect calculation in reverse order dstRect = applyRect; const int directionCoeff = direction == NEED_RECT ? -1 : 1; srcRect = dstRect.translated(directionCoeff * offset); noiseNeedRect = shadow->noise() > 0 ? kisGrowRect(srcRect, KisLsUtils::noiseNeedBorder) : srcRect; blurNeedRect = blur_size ? KisLsUtils::growRectFromRadius(noiseNeedRect, blur_size) : noiseNeedRect; spreadNeedRect = spread_size ? KisLsUtils::growRectFromRadius(blurNeedRect, spread_size) : blurNeedRect; // dbgKrita << ppVar(dstRect); // dbgKrita << ppVar(srcRect); // dbgKrita << ppVar(noiseNeedRect); // dbgKrita << ppVar(blurNeedRect); // dbgKrita << ppVar(spreadNeedRect); }
void bumpmap (KisPixelSelectionSP device, const QRect &selectionRect, const bumpmap_vals_t &bmvals) { KIS_ASSERT_RECOVER_RETURN(bmvals.xofs == 0); KIS_ASSERT_RECOVER_RETURN(bmvals.yofs == 0); bumpmap_params_t params; bumpmap_init_params (¶ms, bmvals); const QRect dataRect = kisGrowRect(selectionRect, 1); const int dataRowSize = dataRect.width() * sizeof(quint8); const int selectionRowSize = selectionRect.width() * sizeof(quint8); QScopedArrayPointer<quint8> dstRow(new quint8[selectionRowSize]); QScopedArrayPointer<quint8> bmRow1(new quint8[dataRowSize]); QScopedArrayPointer<quint8> bmRow2(new quint8[dataRowSize]); QScopedArrayPointer<quint8> bmRow3(new quint8[dataRowSize]); device->readBytes(bmRow1.data(), dataRect.left(), dataRect.top(), dataRect.width(), 1); device->readBytes(bmRow2.data(), dataRect.left(), dataRect.top() + 1, dataRect.width(), 1); device->readBytes(bmRow3.data(), dataRect.left(), dataRect.top() + 2, dataRect.width(), 1); convertRow(bmRow1.data(), dataRect.width(), params.lut); convertRow(bmRow2.data(), dataRect.width(), params.lut); convertRow(bmRow3.data(), dataRect.width(), params.lut); for (int row = selectionRect.top(); row < selectionRect.top() + selectionRect.height(); row++) { bumpmap_row (bmvals, dstRow.data(), selectionRect.width(), bmRow1.data() + 1, bmRow2.data() + 1, bmRow3.data() + 1, ¶ms); device->writeBytes(dstRow.data(), selectionRect.left(), row, selectionRect.width(), 1); bmRow1.swap(bmRow2); bmRow2.swap(bmRow3); device->readBytes(bmRow3.data(), dataRect.left(), row + 1, dataRect.width(), 1); convertRow(bmRow3.data(), dataRect.width(), params.lut); } }
void KisNodeDelegate::drawThumbnail(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const { KisNodeViewColorScheme scm; const int thumbSize = scm.thumbnailSize(); const qreal oldOpacity = p->opacity(); // remember previous opacity QImage img = index.data(int(KisNodeModel::BeginThumbnailRole) + thumbSize).value<QImage>(); if (!(option.state & QStyle::State_Enabled)) { p->setOpacity(0.35); } QRect fitRect = scm.relThumbnailRect().translated(option.rect.topLeft()); QPoint offset; offset.setX((fitRect.width() - img.width()) / 2); offset.setY((fitRect.height() - img.height()) / 2); offset += fitRect.topLeft(); KisConfig cfg; // paint in a checkerboard pattern behind the layer contents to represent transparent const int step = scm.thumbnailSize() / 6; QImage checkers(2 * step, 2 * step, QImage::Format_ARGB32); QPainter gc(&checkers); gc.fillRect(QRect(0, 0, step, step), cfg.checkersColor1()); gc.fillRect(QRect(step, 0, step, step), cfg.checkersColor2()); gc.fillRect(QRect(step, step, step, step), cfg.checkersColor1()); gc.fillRect(QRect(0, step, step, step), cfg.checkersColor2()); QBrush brush(checkers); p->setBrushOrigin(offset); p->fillRect(img.rect().translated(offset), brush); p->drawImage(offset, img); p->setOpacity(oldOpacity); // restore old opacity QRect borderRect = kisGrowRect(img.rect(), 1).translated(offset); KritaUtils::renderExactRect(p, borderRect, scm.gridColor(option, d->view)); }
void KisNodeDelegate::drawThumbnail(QPainter *p, const QStyleOptionViewItem &option, const QModelIndex &index) const { KisNodeViewColorScheme scm; const int thumbSize = scm.thumbnailSize(); const qreal oldOpacity = p->opacity(); // remember previous opacity QImage img = index.data(int(KisNodeModel::BeginThumbnailRole) + thumbSize).value<QImage>(); if (!(option.state & QStyle::State_Enabled)) { p->setOpacity(0.35); } QRect fitRect = scm.relThumbnailRect().translated(option.rect.topLeft()); QPoint offset; offset.setX((fitRect.width() - img.width()) / 2); offset.setY((fitRect.height() - img.height()) / 2); offset += fitRect.topLeft(); // { // paint the checkers: we need a proper GUI design for them to be uncommented // const int step = scm.thumbnailSize() / 4; // QImage checkers(2 * step, 2 * step, QImage::Format_ARGB32); // QPainter gc(&checkers); // gc.fillRect(QRect(0, 0, step, step), Qt::white); // gc.fillRect(QRect(step, 0, step, step), Qt::gray); // gc.fillRect(QRect(step, step, step, step), Qt::white); // gc.fillRect(QRect(0, step, step, step), Qt::gray); // QBrush brush(checkers); // p->setBrushOrigin(offset); // p->fillRect(img.rect().translated(offset), brush);*/ // } p->fillRect(img.rect().translated(offset), Qt::white); p->drawImage(offset, img); p->setOpacity(oldOpacity); // restore old opacity QRect borderRect = kisGrowRect(img.rect(), 1).translated(offset); KritaUtils::renderExactRect(p, borderRect, scm.gridColor(option, d->view)); }