PyAPI: add planes argument to imbuf.new & improve planes docstring

This makes it possible to create grayscale/RGB images,
with/without an alpha channel.
This commit is contained in:
Campbell Barton 2026-03-16 02:09:49 +00:00
parent 3152423683
commit 6944a44e2a
2 changed files with 43 additions and 7 deletions

View file

@ -393,6 +393,20 @@ class TestImBufIO(unittest.TestCase):
ibuf_loaded.free()
class TestImBufPlanes(unittest.TestCase):
def test_new_planes_values(self):
for p in (8, 16, 24, 32):
ibuf = imbuf.new((2, 2), planes=p)
self.assertEqual(ibuf.planes, p)
ibuf.free()
def test_new_planes_invalid(self):
for p in (0, 4, 12, 64):
with self.assertRaises(ValueError):
imbuf.new((2, 2), planes=p)
def main():
import sys
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])