void KisPaintDeviceTest::testCreation() { const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8(); KisPaintDeviceSP dev = new KisPaintDevice(cs); QVERIFY(dev->objectName().isEmpty()); dev = new KisPaintDevice(cs); QVERIFY(*dev->colorSpace() == *cs); QVERIFY(dev->x() == 0); QVERIFY(dev->y() == 0); QVERIFY(dev->pixelSize() == cs->pixelSize()); QVERIFY(dev->channelCount() == cs->channelCount()); QVERIFY(dev->dataManager() != 0); KisImageSP image = new KisImage(0, 1000, 1000, cs, "merge test"); KisPaintLayerSP layer = new KisPaintLayer(image, "bla", 125); dev = new KisPaintDevice(layer.data(), cs); QVERIFY(*dev->colorSpace() == *cs); QVERIFY(dev->x() == 0); QVERIFY(dev->y() == 0); QVERIFY(dev->pixelSize() == cs->pixelSize()); QVERIFY(dev->channelCount() == cs->channelCount()); QVERIFY(dev->dataManager() != 0); // Let the layer go out of scope and see what happens { KisPaintLayerSP l2 = new KisPaintLayer(image, "blabla", 250); dev = new KisPaintDevice(l2.data(), cs); } }
void KisPasteNewActionFactory::run(KisView2 *view) { Q_UNUSED(view); KisPaintDeviceSP clip = KisClipboard::instance()->clip(QRect(), true); if (!clip) return; QRect rect = clip->exactBounds(); if (rect.isEmpty()) return; KisDoc2 *doc = new KisDoc2(); if (!doc) return; KisImageSP image = new KisImage(doc->createUndoStore(), rect.width(), rect.height(), clip->colorSpace(), i18n("Pasted")); KisPaintLayerSP layer = new KisPaintLayer(image.data(), clip->objectName(), OPACITY_OPAQUE_U8, clip->colorSpace()); KisPainter p(layer->paintDevice()); p.setCompositeOp(COMPOSITE_COPY); p.bitBlt(0, 0, clip, rect.x(), rect.y(), rect.width(), rect.height()); p.end(); image->addNode(layer.data(), image->rootLayer()); doc->setCurrentImage(image); KoMainWindow *win = doc->documentPart()->createMainWindow(); win->show(); win->setRootDocument(doc); }
void KisPasteNewActionFactory::run(KisViewManager *viewManager) { Q_UNUSED(viewManager); KisPaintDeviceSP clip = KisClipboard::instance()->clip(QRect(), true); if (!clip) return; QRect rect = clip->exactBounds(); if (rect.isEmpty()) return; KisDocument *doc = KisPart::instance()->createDocument(); KisImageSP image = new KisImage(doc->createUndoStore(), rect.width(), rect.height(), clip->colorSpace(), i18n("Pasted")); KisPaintLayerSP layer = new KisPaintLayer(image.data(), clip->objectName(), OPACITY_OPAQUE_U8, clip->colorSpace()); KisPainter::copyAreaOptimized(QPoint(), clip, layer->paintDevice(), rect); image->addNode(layer.data(), image->rootLayer()); doc->setCurrentImage(image); KisPart::instance()->addDocument(doc); KisMainWindow *win = viewManager->mainWindow(); win->addViewAndNotifyLoadingCompleted(doc); }
void KisPasteNewActionFactory::run(KisView2 *view) { Q_UNUSED(view); KisPaintDeviceSP clip = KisClipboard::instance()->clip(QPoint()); if (!clip) return; QRect rect = clip->exactBounds(); if (rect.isEmpty()) return; const QByteArray mimetype = KoServiceProvider::readNativeFormatMimeType(); KoDocumentEntry entry = KoDocumentEntry::queryByMimeType(mimetype); QString error; KisPart2* part = dynamic_cast<KisPart2*>(entry.createKoPart(&error)); if (!part) return; KisDoc2 *doc = new KisDoc2(part); if (!doc) return; part->setDocument(doc); KisImageSP image = new KisImage(doc->createUndoStore(), rect.width(), rect.height(), clip->colorSpace(), i18n("Pasted")); KisPaintLayerSP layer = new KisPaintLayer(image.data(), clip->objectName(), OPACITY_OPAQUE_U8, clip->colorSpace()); KisPainter p(layer->paintDevice()); p.setCompositeOp(COMPOSITE_COPY); p.bitBlt(0, 0, clip, rect.x(), rect.y(), rect.width(), rect.height()); p.end(); image->addNode(layer.data(), image->rootLayer()); doc->setCurrentImage(image); KoMainWindow *win = new KoMainWindow(part->componentData()); win->show(); win->setRootDocument(doc); }