forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extmod/modframebuf: Enable blit between different formats via a palette.
This achieves a substantial performance improvement when rendering glyphs to color displays, the benefit increasing proportional to the number of pixels in the glyph.
- Loading branch information
1 parent
996f703
commit 2296df0
Showing
4 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Test blit between different color spaces | ||
try: | ||
import framebuf, usys | ||
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) | ||
print(fbd.pixel(8, 8) == 0) # Ouside blit | ||
print(fbd.pixel(0, 1) == bg) | ||
print(fbd.pixel(1, 0) == bg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
True | ||
True | ||
True | ||
True | ||
True |