本文整理汇总了C++中KisImageWSP::bounds方法的典型用法代码示例。如果您正苦于以下问题:C++ KisImageWSP::bounds方法的具体用法?C++ KisImageWSP::bounds怎么用?C++ KisImageWSP::bounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisImageWSP
的用法示例。
在下文中一共展示了KisImageWSP::bounds方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Private
Private(KisDocument *document, int fromTime, int toTime)
: document(document),
image(document->image()),
firstFrame(fromTime),
lastFrame(toTime),
tmpDoc(KisPart::instance()->createDocument()),
exporting(false),
batchMode(false)
{
tmpDoc->setAutoSave(0);
tmpImage = new KisImage(tmpDoc->createUndoStore(),
image->bounds().width(),
image->bounds().height(),
image->colorSpace(),
QString());
tmpImage->setResolution(image->xRes(), image->yRes());
tmpDoc->setCurrentImage(tmpImage);
KisPaintLayer* paintLayer = new KisPaintLayer(tmpImage, "paint device", 255);
tmpImage->addNode(paintLayer, tmpImage->rootLayer(), KisLayerSP(0));
tmpDevice = paintLayer->paintDevice();
}
示例2: getLayer
KisImageBuilder_Result CSVSaver::getLayer(CSVLayerRecord* layer, KisDocument* exportDoc, KisKeyframeSP keyframe, const QString &path, int frame, int idx)
{
//render to the temp layer
KisImageWSP image = exportDoc->image();
KisPaintDeviceSP device = image->rootLayer()->firstChild()->projection();
layer->channel->fetchFrame(keyframe, device);
QRect bounds = device->exactBounds();
if (bounds.isEmpty()) {
layer->last = ""; //empty frame
return KisImageBuilder_RESULT_OK;
}
layer->last = QString("frame%1-%2.png").arg(idx + 1,5,10,QChar('0')).arg(frame,5,10,QChar('0'));
QString filename = path;
filename.append(layer->last);
//save to PNG
KisSequentialConstIterator it(device, image->bounds());
const KoColorSpace* cs = device->colorSpace();
bool isThereAlpha = false;
do {
if (cs->opacityU8(it.oldRawData()) != OPACITY_OPAQUE_U8) {
isThereAlpha = true;
break;
}
} while (it.nextPixel());
if (!KisPNGConverter::isColorSpaceSupported(cs)) {
device = new KisPaintDevice(*device.data());
KUndo2Command *cmd= device->convertTo(KoColorSpaceRegistry::instance()->rgb8());
delete cmd;
}
KisPNGOptions options;
options.alpha = isThereAlpha;
options.interlace = false;
options.compression = 8;
options.tryToSaveAsIndexed = false;
options.transparencyFillColor = QColor(0,0,0);
options.saveSRGBProfile = true; //TVPaint can use only sRGB
options.forceSRGB = false;
KisPNGConverter kpc(exportDoc);
KisImageBuilder_Result result = kpc.buildFile(QUrl::fromLocalFile(filename), image->bounds(),
image->xRes(), image->yRes(), device,
image->beginAnnotations(), image->endAnnotations(),
options, (KisMetaData::Store* )0 );
return result;
}
示例3: copyFromDevice
void copyFromDevice(KisViewManager *view, KisPaintDeviceSP device, bool makeSharpClip = false)
{
KisImageWSP image = view->image();
if (!image) return;
KisSelectionSP selection = view->selection();
QRect rc = (selection) ? selection->selectedExactRect() : image->bounds();
KisPaintDeviceSP clip = new KisPaintDevice(device->colorSpace());
Q_CHECK_PTR(clip);
const KoColorSpace *cs = clip->colorSpace();
// TODO if the source is linked... copy from all linked layers?!?
// Copy image data
KisPainter::copyAreaOptimized(QPoint(), device, clip, rc);
if (selection) {
// Apply selection mask.
KisPaintDeviceSP selectionProjection = selection->projection();
KisHLineIteratorSP layerIt = clip->createHLineIteratorNG(0, 0, rc.width());
KisHLineConstIteratorSP selectionIt = selectionProjection->createHLineIteratorNG(rc.x(), rc.y(), rc.width());
const KoColorSpace *selCs = selection->projection()->colorSpace();
for (qint32 y = 0; y < rc.height(); y++) {
for (qint32 x = 0; x < rc.width(); x++) {
/**
* Sharp method is an exact reverse of COMPOSITE_OVER
* so if you cover the cut/copied piece over its source
* you get an exactly the same image without any seams
*/
if (makeSharpClip) {
qreal dstAlpha = cs->opacityF(layerIt->rawData());
qreal sel = selCs->opacityF(selectionIt->oldRawData());
qreal newAlpha = sel * dstAlpha / (1.0 - dstAlpha + sel * dstAlpha);
float mask = newAlpha / dstAlpha;
cs->applyAlphaNormedFloatMask(layerIt->rawData(), &mask, 1);
} else {
cs->applyAlphaU8Mask(layerIt->rawData(), selectionIt->oldRawData(), 1);
}
layerIt->nextPixel();
selectionIt->nextPixel();
}
layerIt->nextRow();
selectionIt->nextRow();
}
}
KisClipboard::instance()->setClip(clip, rc.topLeft());
}
示例4: run
void KisPasteActionFactory::run(KisView2 *view)
{
KisImageWSP image = view->image();
//figure out where to position the clip
// XXX: Fix this for internal points & zoom! (BSAR)
QWidget * w = view->canvas();
QPoint center = QPoint(w->width() / 2, w->height() / 2);
QPoint bottomright = QPoint(w->width(), w->height());
if (bottomright.x() > image->width())
center.setX(image->width() / 2);
if (bottomright.y() > image->height())
center.setY(image->height() / 2);
const KoCanvasBase* canvasBase = view->canvasBase();
const KoViewConverter* viewConverter = view->canvasBase()->viewConverter();
KisPaintDeviceSP clip = KisClipboard::instance()->clip(
QPoint(
viewConverter->viewToDocumentX(canvasBase->canvasController()->canvasOffsetX()) + center.x(),
viewConverter->viewToDocumentY(canvasBase->canvasController()->canvasOffsetY()) + center.y()));
if (clip) {
// Pasted layer content could be outside image bounds and invisible, if that is the case move content into the bounds
QRect exactBounds = clip->exactBounds();
if (!exactBounds.isEmpty() && !exactBounds.intersects(image->bounds())) {
clip->setX(clip->x() - exactBounds.x());
clip->setY(clip->y() - exactBounds.y());
}
KisPaintLayer *newLayer = new KisPaintLayer(image.data(), image->nextLayerName() + i18n("(pasted)"), OPACITY_OPAQUE_U8, clip);
KisNodeSP aboveNode = view->activeLayer();
KisNodeSP parentNode = aboveNode ? aboveNode->parent() : image->root();
KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode);
KisProcessingApplicator *ap = beginAction(view, cmd->text());
ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
endAction(ap, KisOperationConfiguration(id()).toXML());
} else {
#ifdef __GNUC__
#warning "Add saving of XML data for Paste of shapes"
#endif
view->canvasBase()->toolProxy()->paste();
}
}
示例5: play
void KisRecordedFilterAction::play(KisNodeSP node, const KisPlayInfo& _info, KoUpdater* _updater) const
{
KisFilterConfiguration * kfc = d->configuration();
KisPaintDeviceSP dev = node->paintDevice();
KisLayerSP layer = dynamic_cast<KisLayer*>(node.data());
QRect r1 = dev->extent();
KisTransaction transaction(kundo2_i18n("Filter: \"%1\"", d->filter->name()), dev);
KisImageWSP image = _info.image();
r1 = r1.intersected(image->bounds());
if (layer && layer->selection()) {
r1 = r1.intersected(layer->selection()->selectedExactRect());
}
d->filter->process(dev, dev, layer->selection(), r1, kfc, _updater);
node->setDirty(r1);
transaction.commit(_info.undoAdapter());
}
示例6: copyFromDevice
void copyFromDevice(KisView2 *view, KisPaintDeviceSP device) {
KisImageWSP image = view->image();
KisSelectionSP selection = view->selection();
QRect rc = (selection) ? selection->selectedExactRect() : image->bounds();
KisPaintDeviceSP clip = new KisPaintDevice(device->colorSpace());
Q_CHECK_PTR(clip);
const KoColorSpace *cs = clip->colorSpace();
// TODO if the source is linked... copy from all linked layers?!?
// Copy image data
KisPainter gc;
gc.begin(clip);
gc.setCompositeOp(COMPOSITE_COPY);
gc.bitBlt(0, 0, device, rc.x(), rc.y(), rc.width(), rc.height());
gc.end();
if (selection) {
// Apply selection mask.
KisPaintDeviceSP selectionProjection = selection->projection();
KisHLineIteratorSP layerIt = clip->createHLineIteratorNG(0, 0, rc.width());
KisHLineConstIteratorSP selectionIt = selectionProjection->createHLineIteratorNG(rc.x(), rc.y(), rc.width());
for (qint32 y = 0; y < rc.height(); y++) {
for (qint32 x = 0; x < rc.width(); x++) {
cs->applyAlphaU8Mask(layerIt->rawData(), selectionIt->oldRawData(), 1);
layerIt->nextPixel();
selectionIt->nextPixel();
}
layerIt->nextRow();
selectionIt->nextRow();
}
}
KisClipboard::instance()->setClip(clip, rc.topLeft());
}
示例7: run
void KisPasteActionFactory::run(KisViewManager *view)
{
KisImageWSP image = view->image();
if (!image) return;
KisPaintDeviceSP clip = KisClipboard::instance()->clip(image->bounds(), true);
if (clip) {
KisPaintLayer *newLayer = new KisPaintLayer(image.data(), image->nextLayerName() + i18n("(pasted)"), OPACITY_OPAQUE_U8, clip);
KisNodeSP aboveNode = view->activeLayer();
KisNodeSP parentNode = aboveNode ? aboveNode->parent() : image->root();
KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode);
KisProcessingApplicator *ap = beginAction(view, cmd->text());
ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
endAction(ap, KisOperationConfiguration(id()).toXML());
} else {
// XXX: "Add saving of XML data for Paste of shapes"
view->canvasBase()->toolProxy()->paste();
}
}