mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 05:00:26 +01:00
extmod/modframebuf: Allow blit source to be a subclass of FrameBuffer.
This commit is contained in:
committed by
Damien George
parent
f6d99bc795
commit
f8449dd092
@@ -18,3 +18,25 @@ fb = FB(n=3)
|
||||
fb.pixel(0, 0, 0x0102)
|
||||
fb.foo()
|
||||
print(bytes(fb))
|
||||
|
||||
# Test that blitting a subclass works.
|
||||
fb2 = framebuf.FrameBuffer(bytearray(2 * 3 * 3), 3, 3, framebuf.RGB565)
|
||||
fb.fill(0)
|
||||
fb.pixel(0, 0, 0x0506)
|
||||
fb.pixel(2, 2, 0x0708)
|
||||
fb2.blit(fb, 0, 0)
|
||||
print(bytes(fb2))
|
||||
|
||||
# Test that blitting something that isn't a subclass fails with TypeError.
|
||||
class NotAFrameBuf:
|
||||
pass
|
||||
|
||||
try:
|
||||
fb.blit(NotAFrameBuf(), 0, 0)
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
try:
|
||||
fb.blit(None, 0, 0)
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
b'\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x03\x04\x03\x04\x03'
|
||||
b'\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x07'
|
||||
TypeError
|
||||
TypeError
|
||||
|
||||
Reference in New Issue
Block a user