MCPcopy Create free account
hub / github.com/KDE/krita / nodeToImage

Function nodeToImage

plugins/python/batch_exporter/Infrastructure.py:25–51  ·  view source on GitHub ↗

Returns an QImage 8-bit sRGB

(wnode)

Source from the content-addressed store, hash-verified

23
24
25def nodeToImage(wnode):
26 """
27 Returns an QImage 8-bit sRGB
28 """
29 icc_profile = wnode.meta.get("icc")
30 if not icc_profile and wnode.inherit:
31 icc_profile = wnode.inheritedMetadata().get("icc")
32 if not icc_profile:
33 icc_profile = wnode.cfg["meta"]["icc"]
34
35 icc_profile = icc_profile[0]
36 [x, y, w, h] = wnode.bounds
37
38 conversion_not_needed = (
39 wnode.node.colorModel() == "RGBA"
40 and wnode.node.colorDepth() == "U8"
41 and wnode.node.colorProfile().lower() == icc_profile.lower()
42 )
43
44 if conversion_not_needed:
45 pixel_data = wnode.node.projectionPixelData(x, y, w, h).data()
46 else:
47 temp_node = wnode.node.duplicate()
48 temp_node.setColorSpace("RGBA", "U8", icc_profile)
49 pixel_data = temp_node.projectionPixelData(x, y, w, h).data()
50
51 return QImage(pixel_data, w, h, QImage.Format.Format_ARGB32)
52
53
54def expandAndFormat(img, margin=0, is_jpg=False):

Callers 3

saveMethod · 0.85
saveCOAMethod · 0.85
saveCOASpriteSheetMethod · 0.85

Calls 10

inheritedMetadataMethod · 0.80
projectionPixelDataMethod · 0.80
QImageClass · 0.50
getMethod · 0.45
colorModelMethod · 0.45
colorDepthMethod · 0.45
colorProfileMethod · 0.45
dataMethod · 0.45
duplicateMethod · 0.45
setColorSpaceMethod · 0.45

Tested by

no test coverage detected