Using PSD plugin for Paint.Net, Layer relationship can be found from the AdditionalInfo of each Layer.
- PSDFile.Layers contains ordered list of Layers (reverse order compared with PhotoShop)
- Foreach Layer, if it has a LayerSectionInfo in its AdditionalInfo property, then it is an important node for recreate the layer tree.
- Find out the LayerSectionType of Layer.AdditionalInfo[index of LayerSectionInfo].SectionType.
- If it is OpenFolder or ClosedFolder, then it is a parent layer and a open tag, layers after it are its children;
- if it is SectionDivider, then it is a close tag layer indicate end of current layer group;
- if LayerSectionInfo does not exist, then it is a common layer node.
for example, layers look like this:
(OF for OpenFolder, L(SD) for Layer which is SectionDivider)
[A(OF), A0, A1(OF), A10, L(SD), L(SD), B(OF), B0(OF), B00, L(SD), B1, L(SD)]
can be translate to this layer tree: