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

            Bug ID: 495708
           Summary: Node.scaleNode doesn't work when parent node is None
    Classification: Applications
           Product: krita
           Version: nightly build (please specify the git hash!)
          Platform: Other
                OS: Microsoft Windows
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Scripting
          Assignee: krita-bugs-n...@kde.org
          Reporter: evan.lee...@gmail.com
  Target Milestone: ---

Version: 5.3.0-prealpha (git e031c83)
OS: Windows 11

Node.scaleNode fails to work on freshly created nodes not yet added to the
document node tree. It doesn't work if I scale the node then add it to the
tree. It works as expected if I add the node to the tree then scale it.

```python
from krita import *

def loadImageToNode(image: QImage, node: Node) -> None:
    # The format is hardcoded. Maybe condition on it later.
    image.convertToFormat(QImage.Format_ARGB32)
    w = image.width()
    h = image.height()
    size = 4*w*h
    imageData = image.constBits().asstring(size)
    node.setPixelData(imageData, 0, 0, w, h)

doc = Krita.instance().activeDocument()

image = QImage('<path to image>')
node = doc.createNode('asdf', 'paintlayer')
loadImageToNode(image, node)

activeNode = doc.activeNode()
parentNode = activeNode.parentNode()
parentNode.addChildNode(node, activeNode)

r = node.bounds()
node.scaleNode(QPointF(0,0), int(r.width()*0.48), int(r.height()*0.48),
'Bicubic')
print(int(r.width()*0.48), int(r.height()*0.48))

doc.refreshProjection()
```

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

Reply via email to