Summary: | Node::projectionPixelData returns 0s for grouplayer and wrong data for filelayer | ||
---|---|---|---|
Product: | [Applications] krita | Reporter: | Razvan Radulescu <razcore.rad> |
Component: | Scripting | Assignee: | Krita Bugs <krita-bugs-null> |
Status: | RESOLVED NOT A BUG | ||
Severity: | normal | CC: | griffinvalley |
Priority: | NOR | ||
Version: | nightly build (please specify the git hash!) | ||
Target Milestone: | --- | ||
Platform: | Appimage | ||
OS: | Linux | ||
Latest Commit: | https://commits.kde.org/krita/301ebfc6ef375cda5a8f9997cffa8bcdea63f145 | Version Fixed In: | |
Sentry Crash Report: | |||
Attachments: |
test kra and export files
Other test kra file |
Description
Razvan Radulescu
2018-12-20 14:42:04 UTC
That group layers don't work is weird because it does seem to work in the save_group_layers function in layers->export, in code as 'KisSaveGroupVisitor.cpp) --------------------------------------------------------------------------------- KisImageSP dst = new KisImage(exportDocument->createUndoStore(), r.width(), r.height(), m_image->colorSpace(), layer->name()); dst->setResolution(m_image->xRes(), m_image->yRes()); exportDocument->setCurrentImage(dst); KisPaintLayer* paintLayer = new KisPaintLayer(dst, "projection", layer->opacity()); KisPainter gc(paintLayer->paintDevice()); gc.bitBlt(QPoint(0, 0), layer->projection(), r); dst->addNode(paintLayer, dst->rootLayer(), KisLayerSP(0)); dst->refreshGraph(); ---------------------------------------------------------------------------- File layer in turn use the projection() defined in Kis_Layer.cc, which is also used by clone layers. I'm at this point going to do a test script first. Created attachment 117597 [details]
Other test kra file
Okay, I made a test file and a test script. The script basically copies the pixeldata to a seperate document.
I am not seeing any issues with vector, clone, file or group layers. I am seeing issues with mask-style layers, and I am seeing crashes when we call projectionPixelData on transform masks. Colorize masks work sensibly. I guess this is caused by colorize masks having an rgba color projection, while the alpha based masks do not. These alpha based masks report the color model as RGBA despite them being alpha cs too...
Note that the below script would need to be modified to handle multiple depths, so groups inside groups, but it should otherwise work for most files.
---------------------------------------------------------------------------------
from krita import *
doc = Application.activeDocument()
destDoc = Application.createDocument(doc.width(), doc.height(), "projection", doc.colorModel(), doc.colorDepth(), doc.colorProfile(), doc.resolution())
for node in doc.rootNode().childNodes():
newNode = destDoc.createNode(node.type(), "paintlayer")
ba = node.projectionPixelData(0, 0, doc.width(), doc.height())
newNode.setPixelData(ba, 0, 0, doc.width(), doc.height())
print(node.type(), node.name(), node.colorModel(), ba.size())
destDoc.rootNode().addChildNode(newNode, None)
if len(node.childNodes())>0:
for childNode in node.childNodes():
if str(childNode.type()) != "transformmask":
newNode = destDoc.createNode(childNode.type(), "paintlayer")
ba = childNode.projectionPixelData(0, 0, doc.width(), doc.height())
print(childNode.type(), childNode.name(), childNode.colorModel(), ba.size())
newNode.setPixelData(ba, 0, 0, doc.width(), doc.height())
destDoc.rootNode().addChildNode(newNode, None)
destDoc.refreshProjection()
Application.activeWindow().addView(destDoc)
My script cannot reproduce with the test file offered by Razvan, there must be an issue with his script. That said, the transparency, filter and selection masks need to report the appropriate color model for the bytearray they deliver(this is currently incorrect, it delivers a Alpha colorspace bytearray, but reports RGBA). Also, we need to stop the transform mask from crashing when requesting projection data. I'll set it confirmed for those two. Git commit c90bdf5301ca24460c0039e642860c01ac754605 by Wolthera van Hövell tot Westerflier. Committed on 21/01/2019 at 16:50. Pushed by woltherav into branch 'master'. Fix crash when trying to access projectionpixeldata on transform mask. This one was found when trying to figure out whether projection data works properly. M +2 -0 libs/libkis/Node.cpp https://commits.kde.org/krita/c90bdf5301ca24460c0039e642860c01ac754605 Git commit 301ebfc6ef375cda5a8f9997cffa8bcdea63f145 by Wolthera van Hövell tot Westerflier. Committed on 21/01/2019 at 17:09. Pushed by woltherav into branch 'master'. Return the colorspace of the projection before returning the colorspace of the node. This is necessary to access the alpha color space of the mask and transparency masks. This way the user can first convert a layer to that colorspace, then copy over the bytearray and then convert back. This works with both projectionPixelData and regular pixelData. Auditors: rempt M +6 -3 libs/libkis/Node.cpp https://commits.kde.org/krita/301ebfc6ef375cda5a8f9997cffa8bcdea63f145 Ok, I've fixed both issues I've found. I can only reproduce this bug when I use Node::pixelData, but not with Node::projectionPixelData now. Please check. And by reproduce I mean it is sorta expected with Node::pixeldata, the bug would only be if it happened with node::projectionpixeldata. OK so I think we went through a lot in the IRC chat. I'll have to book mark this for later, the script is really helpful. At the end of the day it's because of Node.setColorProfile() and likewise I tried Document.setColorProfile() with no luck. As for the file layer I've tried another .kra file so that was the issue there. I'm going to close this as pretty much all has been answered, as much as it could have been :) Thanks for all the help Wolthera |