MCPcopy Index your code
hub / github.com/plotly/plotly.py / make_palette_chunks

Function make_palette_chunks

_plotly_utils/png.py:1006–1023  ·  view source on GitHub ↗

Create the byte sequences for a ``PLTE`` and if necessary a ``tRNS`` chunk. Returned as a pair (*p*, *t*). *t* will be ``None`` if no ``tRNS`` chunk is necessary.

(palette)

Source from the content-addressed store, hash-verified

1004
1005
1006def make_palette_chunks(palette):
1007 """
1008 Create the byte sequences for a ``PLTE`` and
1009 if necessary a ``tRNS`` chunk.
1010 Returned as a pair (*p*, *t*).
1011 *t* will be ``None`` if no ``tRNS`` chunk is necessary.
1012 """
1013
1014 p = bytearray()
1015 t = bytearray()
1016
1017 for x in palette:
1018 p.extend(x[0:3])
1019 if len(x) > 3:
1020 t.append(x[3])
1021 if t:
1022 return p, t
1023 return p, None
1024
1025
1026def check_bitdepth_rescale(palette, bitdepth, transparent, alpha, greyscale):

Callers 1

write_preambleMethod · 0.85

Calls 1

extendMethod · 0.45

Tested by

no test coverage detected