Bug 459026

Summary: Node class, projectionPixelData and all related method doesn't takes in account layer style
Product: [Applications] krita Reporter: grum999
Component: ScriptingAssignee: Krita Bugs <krita-bugs-null>
Status: CONFIRMED ---    
Severity: normal CC: halla
Priority: NOR    
Version First Reported In: 5.1.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: A krita file that can be used for example

Description grum999 2022-09-12 17:25:23 UTC
Created attachment 152004 [details]
A krita file that can be used for example

SUMMARY
The following Python API function don't work properly:
- save()
- projectionPixelData()
- thumbnail() 

If layer have a layer style, layer style is not taken in account when saving/return data
If layer have a filter mask, filter mask is properly taken in account

STEPS TO REPRODUCE
1. Create a document with a paint layer, draw something 
2. Add a filter mask (gaussian blur for example)
3. Add a layer style (a stroke for example)
4. In scripter, execute the following code:
```
from krita import *
from PyQt5.Qt import *

def toQImage(layerNode):
    rect = layerNode.bounds()
    return QImage(layerNode.projectionPixelData(rect.left(), rect.top(), rect.width(), rect.height()), rect.width(), rect.height(), QImage.Format_ARGB32)

ad=Krita.instance().activeDocument()
ad.refreshProjection()
n=ad.activeNode()

options=InfoObject()

n.save("/home/grum/test_layer.png", 72, 72, options, QRect())

lbl=QLabel()
lbl.setPixmap(QPixmap.fromImage(toQImage(n)))
layout=QVBoxLayout()
layout.addWidget(lbl)

dlg=QDialog()
dlg.setLayout(layout)
dlg.exec()
```

OBSERVED RESULT
- On exported PNG file (save method), the filter mask is applied but not the layer style
- On displayed image (projectionPixelData method), the filter mask is applied but not the layer style

EXPECTED RESULT
Layer style should be applied as for filter mask 

Note: pixelData() method doesn't take in account layer style and filters mask ==> it's normal and this method shouldn't be impacted by bug fix

SOFTWARE/OS VERSIONS
Tested on Linux appimage, on version 4.4.3, 4.4.8, 5.1.0 ==> problem is here from a while
Comment 1 grum999 2022-09-12 17:33:04 UTC
I'm wondering if it's not related to this one:
https://bugs.kde.org/show_bug.cgi?id=363064

For clone layer, layer style are not taken in account.
Then maybe the problem is not on API side, but deeper in how projection is calculated?


Grum999
Comment 2 Halla Rempt 2022-09-13 10:25:42 UTC
That's because Node::save doesn't copy the layerstyle and put on the new node that was cloned from the original node.