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)
| 1004 | |
| 1005 | |
| 1006 | def 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 | |
| 1026 | def check_bitdepth_rescale(palette, bitdepth, transparent, alpha, greyscale): |