https://bugs.kde.org/show_bug.cgi?id=402382

--- Comment #2 from wolthera <griffinval...@gmail.com> ---
Created attachment 117597
  --> https://bugs.kde.org/attachment.cgi?id=117597&action=edit
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)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to