2021-08-18 19:05:25 +00:00
|
|
|
# Test blit between different color spaces
|
|
|
|
try:
|
2022-08-18 06:57:45 +00:00
|
|
|
import framebuf, sys
|
2021-08-18 19:05:25 +00:00
|
|
|
except ImportError:
|
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
|
|
|
|
|
|
|
# Monochrome glyph/icon
|
|
|
|
w = 8
|
|
|
|
h = 8
|
|
|
|
cbuf = bytearray(w * h // 8)
|
|
|
|
fbc = framebuf.FrameBuffer(cbuf, w, h, framebuf.MONO_HLSB)
|
|
|
|
fbc.line(0, 0, 7, 7, 1)
|
|
|
|
|
|
|
|
# RGB565 destination
|
|
|
|
wd = 16
|
|
|
|
hd = 16
|
|
|
|
dest = bytearray(wd * hd * 2)
|
|
|
|
fbd = framebuf.FrameBuffer(dest, wd, hd, framebuf.RGB565)
|
|
|
|
|
|
|
|
wp = 2
|
|
|
|
bg = 0x1234
|
|
|
|
fg = 0xF800
|
|
|
|
pal = bytearray(wp * 2)
|
|
|
|
palette = framebuf.FrameBuffer(pal, wp, 1, framebuf.RGB565)
|
|
|
|
palette.pixel(0, 0, bg)
|
|
|
|
palette.pixel(1, 0, fg)
|
|
|
|
|
|
|
|
fbd.blit(fbc, 0, 0, -1, palette)
|
|
|
|
|
|
|
|
print(fbd.pixel(0, 0) == fg)
|
|
|
|
print(fbd.pixel(7, 7) == fg)
|
2023-03-08 03:10:02 +00:00
|
|
|
print(fbd.pixel(8, 8) == 0) # Outside blit
|
2021-08-18 19:05:25 +00:00
|
|
|
print(fbd.pixel(0, 1) == bg)
|
|
|
|
print(fbd.pixel(1, 0) == bg)
|