https://bugs.kde.org/show_bug.cgi?id=475456
Bug ID: 475456 Summary: Reading and writing pixelData from/to node channels doesn't work properly Classification: Applications Product: krita Version: 5.2.0 Platform: Manjaro OS: Linux Status: REPORTED Severity: normal Priority: NOR Component: Scripting Assignee: krita-bugs-n...@kde.org Reporter: chirn...@hotmail.com Target Milestone: --- Created attachment 162210 --> https://bugs.kde.org/attachment.cgi?id=162210&action=edit test krita file 5.2.0-rc1 Appimage SUMMARY Reading the pixelData for the RGBA channels of a node (and printing the output) doesn't seem correct. There is a very slight something in the byte array but it's very nearly all zeros, and copying that channel pixelData to the channel of a new node doesn't produce anything useful. I'm able to use the full node pixelData or projectionPixelData just fine (this is how I'm exporting maps in my plugin currently), but reading/writing channels pixelData seems broken. It doesn't produce any errors, it just doesn't work. I may be doing something wrong (am I?), but I would assume copying from the channel of one node into the channel of another node should be possible, right? For context, I'm trying to pack three grayscale (but RGBA color space) textures into the channels of a single node (ambient occlusion, roughness, metallic, i.e. ORM), but I haven't gotten that far because being able to read/write channel data is the first step and I'm blocked here. STEPS TO REPRODUCE Copy the following script and run it in scripter while the "pixels" layer of the attached .kra file is selected. from krita import Krita from PyQt5.QtCore import QByteArray, QRect KI = Krita.instance() doc = KI.activeDocument() activeNode = doc.activeNode() root = doc.rootNode() fullPixels = QByteArray() rChannel = QByteArray() gChannel = QByteArray() bChannel = QByteArray() aChannel = QByteArray() xDocSize = 3 yDocSize = 1 rect = QRect(0, 0, xDocSize, yDocSize) print("\nOriginal node pixel data") fullPixels = activeNode.pixelData(0, 0, xDocSize, yDocSize) print(fullPixels) print("\n" + activeNode.channels()[2].name()) rChannel = activeNode.channels()[2].pixelData(rect) print(rChannel) print("\n" + activeNode.channels()[1].name()) gChannel = activeNode.channels()[1].pixelData(rect) print(gChannel) print("\n" + activeNode.channels()[0].name()) bChannel = activeNode.channels()[0].pixelData(rect) print(bChannel) print("\n" + activeNode.channels()[3].name()) aChannel = activeNode.channels()[3].pixelData(rect) print(aChannel) newNode = doc.createNode("channels copy (doesnt work)", 'paintlayer') newNode.channels()[2].setPixelData(rChannel, rect) newNode.channels()[1].setPixelData(gChannel, rect) newNode.channels()[0].setPixelData(bChannel, rect) newNode.channels()[3].setPixelData(aChannel, rect) print("\nOriginal channels copied into new node channels") print(newNode.pixelData(0, 0, xDocSize, yDocSize)) fullCopy = doc.createNode("full copy (works)", 'paintlayer') fullCopy.setPixelData(fullPixels, 0, 0, xDocSize, yDocSize) print("\nFull copy of original pixel data into new node") print(fullCopy.pixelData(0, 0, xDocSize, yDocSize)) root.addChildNode(newNode, None) root.addChildNode(fullCopy, None) OBSERVED RESULT 1. It should be clear from the script output that the pixelData for the entire layer seems normal and can be copied to another node properly. A new node will be added to the stack with an exact copy of the pixels. 2. It should also be clear that doing the same thing for the individual channels doesn't produce the desired result. The printed QByteArray output seems wrong, and recomposing a node using the copied channel pixelData produces an empty layer in the stack. EXPECTED RESULT I would expect to be able to read the pixelData of each channel in a node and copy it to a channel in a new node, thereby reconstituting an exact copy of the original node, or swapping channels around. I would also expect to be able to copy the full pixelData from, say, three different nodes and pack those into the individual channels of a new node. -- You are receiving this mail because: You are watching all bug changes.