本文整理汇总了C++中KisImageWSP类的典型用法代码示例。如果您正苦于以下问题:C++ KisImageWSP类的具体用法?C++ KisImageWSP怎么用?C++ KisImageWSP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KisImageWSP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadNodes
KisNodeSP KisKraLoader::loadNodes(const KoXmlElement& element, KisImageWSP image, KisNodeSP parent)
{
KoXmlNode node = element.firstChild();
KoXmlNode child;
if (!node.isNull()) {
if (node.isElement()) {
if (node.nodeName().toUpper() == LAYERS.toUpper() || node.nodeName().toUpper() == MASKS.toUpper()) {
for (child = node.lastChild(); !child.isNull(); child = child.previousSibling()) {
KisNodeSP node = loadNode(child.toElement(), image, parent);
if (node) {
image->nextLayerName(); // Make sure the nameserver is current with the number of nodes.
image->addNode(node, parent);
if (node->inherits("KisLayer") && child.childNodesCount() > 0) {
loadNodes(child.toElement(), image, node);
}
}
}
}
}
}
return parent;
}
示例2: beginAction
void KisSelectAllActionFactory::run(KisView2 *view)
{
KisProcessingApplicator *ap = beginAction(view, i18n("Select All"));
KisImageWSP image = view->image();
if (!image->globalSelection()) {
ap->applyCommand(new KisSetEmptyGlobalSelectionCommand(image),
KisStrokeJobData::SEQUENTIAL,
KisStrokeJobData::EXCLUSIVE);
}
struct SelectAll : public KisTransactionBasedCommand {
SelectAll(KisImageSP image) : m_image(image) {}
KisImageSP m_image;
KUndo2Command* paint() {
KisSelectionSP selection = m_image->globalSelection();
KisSelectionTransaction transaction(QString(), m_image->undoAdapter(), selection);
selection->getOrCreatePixelSelection()->select(m_image->bounds());
return transaction.endAndTake();
}
};
ap->applyCommand(new SelectAll(image),
KisStrokeJobData::SEQUENTIAL,
KisStrokeJobData::EXCLUSIVE);
endAction(ap, KisOperationConfiguration(id()).toXML());
}
示例3: KisResourcesSnapshot
KisFigurePaintingToolHelper::KisFigurePaintingToolHelper(const QString &name,
KisImageWSP image,
KoCanvasResourceManager *resourceManager,
KisPainter::StrokeStyle strokeStyle,
KisPainter::FillStyle fillStyle)
{
m_strokesFacade = image.data();
m_resources =
new KisResourcesSnapshot(image,
image->postExecutionUndoAdapter(),
resourceManager);
m_resources->setStrokeStyle(strokeStyle);
m_resources->setFillStyle(fillStyle);
m_painterInfo =
new PainterInfo(new KisPainter(),
new KisDistanceInformation());
bool indirectPainting = m_resources->needsIndirectPainting();
KisStrokeStrategy *stroke =
new FreehandStrokeStrategy(indirectPainting, m_resources, m_painterInfo, name);
m_strokeId = m_strokesFacade->startStroke(stroke);
}
示例4: checkLayers
bool checkLayers(KisImageWSP image,
const QString &prefix)
{
KisNodeSP layer1 = image->rootLayer()->firstChild();
KisNodeSP layer2 = layer1->nextSibling();
QVector<QImage> images(3);
images[0] = image->projection()->convertToQImage(0, 0, 0, 300, 300);
images[1] = layer1->paintDevice()->convertToQImage(0, 0, 0, 300, 300);
images[2] = layer2->paintDevice()->convertToQImage(0, 0, 0, 300, 300);
QVector<QString> names(3);
names[0] = QString("applicator_") + prefix + "_projection.png";
names[1] = QString("applicator_") + prefix + "_layer1.png";
names[2] = QString("applicator_") + prefix + "_layer2.png";
bool valid = true;
for(int i = 0; i < 3; i++) {
QImage ref(QString(FILES_DATA_DIR) + QDir::separator() +
"applicator" + QDir::separator() + names[i]);
QPoint temp;
if(!TestUtil::compareQImages(temp, ref, images[i], 1)) {
qDebug() << "--- Wrong image:" << names[i];
valid = false;
images[i].save(QString(FILES_OUTPUT_DIR) + QDir::separator() + names[i]);
}
}
return valid;
}
示例5: setImage
void KisDummiesFacadeBase::setImage(KisImageWSP image)
{
if (m_d->image) {
emit sigActivateNode(0);
m_d->image->disconnect(this);
KisNodeDummy *rootDummy = this->rootDummy();
if(rootDummy) {
slotRemoveNode(rootDummy->node());
}
}
m_d->image = image;
if (image) {
slotNodeAdded(image->root());
connect(image, SIGNAL(sigNodeAddedAsync(KisNodeSP)),
SLOT(slotNodeAdded(KisNodeSP)), Qt::DirectConnection);
connect(image, SIGNAL(sigRemoveNodeAsync(KisNodeSP)),
SLOT(slotRemoveNode(KisNodeSP)), Qt::DirectConnection);
connect(image, SIGNAL(sigLayersChangedAsync()),
SLOT(slotLayersChanged()), Qt::DirectConnection);
connect(image, SIGNAL(sigNodeChanged(KisNodeSP)),
SLOT(slotNodeChanged(KisNodeSP)));
connect(image, SIGNAL(sigNodeAddedAsync(KisNodeSP)),
SLOT(slotNodeActivationRequested(KisNodeSP)), Qt::AutoConnection);
emit sigActivateNode(findFirstLayer(image->root()));
}
}
示例6: testObligeSingleChildImpl
void testObligeSingleChildImpl(bool transpDefaultPixel)
{
QString id = !transpDefaultPixel ?
"single_layer_no_channel_flags_nontransp_def_pixel.kra" :
"single_layer_no_channel_flags_transp_def_pixel.kra";
QString fileName = TestUtil::fetchDataFileLazy(id);
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(fileName);
KisImageWSP image = doc->image();
QVERIFY(image);
QCOMPARE(image->nlayers(), 2);
KisNodeSP root = image->root();
KisNodeSP child = root->firstChild();
QVERIFY(child);
QCOMPARE(root->original(), root->projection());
if (transpDefaultPixel) {
QCOMPARE(root->original(), child->projection());
} else {
QVERIFY(root->original() != child->projection());
}
delete doc;
}
示例7: updateGUI
void KisPerspectiveGridManager::updateGUI()
{
KisImageWSP image = m_view->image();
if (image) {
KisPerspectiveGrid* pGrid = image->perspectiveGrid();
m_toggleGrid->setEnabled(pGrid->hasSubGrids());
}
}
示例8: 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());
}
示例9: getImage
QRectF KisNodeShape::boundingRect() const
{
QRect br = m_d->node->extent();
KisImageWSP image = getImage();
return QRectF(int(br.left()) / image->xRes(), int(br.top()) / image->yRes(),
int(1 + br.right()) / image->xRes(), int(1 + br.bottom()) / image->yRes());
}
示例10: clearPerspectiveGrid
void KisPerspectiveGridManager::clearPerspectiveGrid()
{
KisImageWSP image = m_view->image();
if (image) {
image->perspectiveGrid()->clearSubGrids();
m_view->canvas()->update();
m_toggleGrid->setChecked(false);
m_toggleGrid->setEnabled(false);
}
}
示例11: saveXML
QDomElement KisKraSaver::saveXML(QDomDocument& doc, KisImageWSP image)
{
QDomElement imageElement = doc.createElement("IMAGE"); // Legacy!
Q_ASSERT(image);
imageElement.setAttribute(NAME, m_d->imageName);
imageElement.setAttribute(MIME, NATIVE_MIMETYPE);
imageElement.setAttribute(WIDTH, image->width());
imageElement.setAttribute(HEIGHT, image->height());
imageElement.setAttribute(COLORSPACE_NAME, image->colorSpace()->id());
imageElement.setAttribute(DESCRIPTION, m_d->doc->documentInfo()->aboutInfo("comment"));
// XXX: Save profile as blob inside the image, instead of the product name.
if (image->profile() && image->profile()-> valid()) {
imageElement.setAttribute(PROFILE, image->profile()->name());
}
imageElement.setAttribute(X_RESOLUTION, image->xRes()*72.0);
imageElement.setAttribute(Y_RESOLUTION, image->yRes()*72.0);
quint32 count = 1; // We don't save the root layer, but it does count
KisSaveXmlVisitor visitor(doc, imageElement, count, true);
image->rootLayer()->accept(visitor);
m_d->nodeFileNames = visitor.nodeFileNames();
return imageElement;
}
示例12: duplicateOutlineRect
QRectF KisDuplicateOpSettings::duplicateOutlineRect(const QPointF& pos, KisImageWSP image) const
{
// Compute the rectangle for the offset
QRectF rect2 = QRectF(-5, -5, 10, 10);
if (m_isOffsetNotUptodate) {
rect2.translate(m_position);
} else {
rect2.translate(- m_offset + image->documentToPixel(pos));
}
return image->pixelToDocument(rect2);
}
示例13: run
void KisCopyMergedActionFactory::run(KisView2 *view)
{
KisImageWSP image = view->image();
image->barrierLock();
KisPaintDeviceSP dev = image->root()->projection();
ActionHelper::copyFromDevice(view, dev);
image->unlock();
KisProcessingApplicator *ap = beginAction(view, i18n("Copy Merged"));
endAction(ap, KisOperationConfiguration(id()).toXML());
}
示例14: saveBinaryData
bool KisKraSaver::saveBinaryData(KoStore* store, KisImageWSP image, const QString & uri, bool external)
{
QString location;
// Save the layers data
quint32 count = 0;
KisKraSaveVisitor visitor(image, store, count, m_d->imageName, m_d->nodeFileNames);
if (external)
visitor.setExternalUri(uri);
image->rootLayer()->accept(visitor);
// saving annotations
// XXX this only saves EXIF and ICC info. This would probably need
// a redesign of the dtd of the krita file to do this more generally correct
// e.g. have <ANNOTATION> tags or so.
KisAnnotationSP annotation = image->annotation("exif");
if (annotation) {
location = external ? QString::null : uri;
location += m_d->imageName + EXIF_PATH;
if (store->open(location)) {
store->write(annotation->annotation());
store->close();
}
}
if (image->profile()) {
const KoColorProfile *profile = image->profile();
KisAnnotationSP annotation;
if (profile) {
QByteArray profileRawData = profile->rawData();
if (!profileRawData.isEmpty()) {
if (profile->type() == "icc") {
annotation = new KisAnnotation(ICC, profile->name(), profile->rawData());
} else {
annotation = new KisAnnotation(PROFILE, profile->name(), profile->rawData());
}
}
}
if (annotation) {
location = external ? QString::null : uri;
location += m_d->imageName + ICC_PATH;
if (store->open(location)) {
store->write(annotation->annotation());
store->close();
}
}
}
return true;
}
示例15: Q_ASSERT
QSizeF KisNodeShape::size() const
{
Q_ASSERT(m_d);
Q_ASSERT(m_d->node);
QRect br = m_d->node->extent();
KisImageWSP image = getImage();
if (!image) return QSizeF(0.0, 0.0);
dbgUI << "KisNodeShape::size extent:" << br << ", x res:" << image->xRes() << ", y res:" << image->yRes();
return QSizeF(br.width() / image->xRes(), br.height() / image->yRes());
}