Merge remote-tracking branch 'origin/main'
|
@ -664,7 +664,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_readinto_obj, 0, bitmaptools_readinto);
|
|||
//| """The Floyd-Stenberg dither"""
|
||||
//|
|
||||
MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, Atkinson, DITHER_ALGORITHM_ATKINSON);
|
||||
MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, FloydStenberg, DITHER_ALGORITHM_ATKINSON);
|
||||
MAKE_ENUM_VALUE(bitmaptools_dither_algorithm_type, dither_algorithm, FloydStenberg, DITHER_ALGORITHM_FLOYD_STENBERG);
|
||||
|
||||
MAKE_ENUM_MAP(bitmaptools_dither_algorithm) {
|
||||
MAKE_ENUM_MAP_ENTRY(dither_algorithm, Atkinson),
|
||||
|
|
|
@ -749,9 +749,9 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi
|
|||
int x1 = x + info->terms[i].dx;
|
||||
int dy = info->terms[i].dy;
|
||||
|
||||
rows[dy][x1] = ((info->terms[i].dl * err) >> 8) + rows[dy][x1];
|
||||
rows[dy][x1] = ((info->terms[i].dl * err) / 256) + rows[dy][x1];
|
||||
}
|
||||
err = err * info->dl >> 8;
|
||||
err = (err * info->dl) / 256;
|
||||
}
|
||||
write_pixels(dest_bitmap, y, out);
|
||||
|
||||
|
@ -761,13 +761,13 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi
|
|||
rows[1] = rows[2];
|
||||
rows[2] = tmp;
|
||||
|
||||
fill_row(source_bitmap, swap, rows[2], y + 2, info->mx);
|
||||
|
||||
y++;
|
||||
if (y == height) {
|
||||
break;
|
||||
}
|
||||
|
||||
fill_row(source_bitmap, swap, rows[2], y + 2, info->mx);
|
||||
|
||||
// Serpentine dither. Going right-to-left...
|
||||
for (int x = width; x--;) {
|
||||
int16_t pixel_in = rows[0][x] + err;
|
||||
|
@ -779,9 +779,9 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi
|
|||
int x1 = x - info->terms[i].dx;
|
||||
int dy = info->terms[i].dy;
|
||||
|
||||
rows[dy][x1] = ((info->terms[i].dl * err) >> 8) + rows[dy][x1];
|
||||
rows[dy][x1] = ((info->terms[i].dl * err) / 256) + rows[dy][x1];
|
||||
}
|
||||
err = err * info->dl >> 8;
|
||||
err = (err * info->dl) / 256;
|
||||
}
|
||||
write_pixels(dest_bitmap, y, out);
|
||||
|
||||
|
@ -790,7 +790,7 @@ void common_hal_bitmaptools_dither(displayio_bitmap_t *dest_bitmap, displayio_bi
|
|||
rows[1] = rows[2];
|
||||
rows[2] = tmp;
|
||||
|
||||
fill_row(source_bitmap, swap, rows[2], y + 2, info->mx);
|
||||
fill_row(source_bitmap, swap, rows[2], y + 3, info->mx);
|
||||
}
|
||||
|
||||
displayio_area_t a = { 0, 0, width, height, NULL };
|
||||
|
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 150 KiB |
|
@ -0,0 +1,18 @@
|
|||
import bitmaptools
|
||||
import displayio
|
||||
import _bmp16
|
||||
|
||||
if "/" in __file__:
|
||||
here = __file__.rsplit("/", 1)[0]
|
||||
else:
|
||||
here = "."
|
||||
|
||||
c = displayio.Colorspace.BGR565
|
||||
|
||||
b1 = _bmp16.loadbmp16(here + "/minerva16.bmp")
|
||||
b3 = displayio.Bitmap(320, 240, 65536)
|
||||
|
||||
bitmaptools.dither(b3, b1, c)
|
||||
_bmp16.writebmp16(f"dither-atkinson.bmp", b3)
|
||||
bitmaptools.dither(b3, b1, c, bitmaptools.DitherAlgorithm.FloydStenberg)
|
||||
_bmp16.writebmp16(f"dither-floydstenberg.bmp", b3)
|
After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 150 KiB |
|
@ -1,31 +0,0 @@
|
|||
import bitmaptools
|
||||
import displayio
|
||||
import _bmp16
|
||||
|
||||
if "/" in __file__:
|
||||
here = __file__.rsplit("/", 1)[0]
|
||||
else:
|
||||
here = "."
|
||||
|
||||
c = displayio.Colorspace.BGR565
|
||||
|
||||
b1 = _bmp16.loadbmp16(here + "/minerva16.bmp")
|
||||
b3 = displayio.Bitmap(320, 240, 65536)
|
||||
|
||||
for i in (
|
||||
0,
|
||||
1 / 64,
|
||||
3 / 64,
|
||||
3 / 32,
|
||||
3 / 16,
|
||||
0.5,
|
||||
1 - 3 / 16,
|
||||
1 - 3 / 32,
|
||||
1 - 3 / 64,
|
||||
1 - 1 / 64,
|
||||
1,
|
||||
):
|
||||
bitmaptools.dither(b3, b1, c)
|
||||
_bmp16.writebmp16(f"dither-atkinson.bmp", b3)
|
||||
bitmaptools.dither(b3, b1, c, bitmaptools.DitherAlgorithm.FloydStenberg)
|
||||
_bmp16.writebmp16(f"dither-floydstenberg.bmp", b3)
|