22import bitmapfilter
33import ulab
44from dump_bitmap import dump_bitmap_rgb_swapped
5- from blinka_image import decode_blinka
5+ from blinka_image import decode_resource
6+
7+
8+ def test_pattern ():
9+ return decode_resource ("testpattern" , 2 )
610
711
812def make_quadrant_bitmap ():
@@ -14,7 +18,7 @@ def make_quadrant_bitmap():
1418
1519
1620q = make_quadrant_bitmap ()
17- b = decode_blinka ( 3 )
21+ b = test_pattern ( )
1822dump_bitmap_rgb_swapped (b )
1923
2024sepia_weights = [0.393 , 0.769 , 0.189 , 0.349 , 0.686 , 0.168 , 0.272 , 0.534 , 0.131 ]
@@ -25,18 +29,24 @@ def make_quadrant_bitmap():
2529
2630# Red channel only
2731print ("red channel only (note: masked)" )
28- b = decode_blinka ( 3 )
32+ b = test_pattern ( )
2933bitmapfilter .mix (b , [1 , 0 , 0 ], mask = q )
3034dump_bitmap_rgb_swapped (b )
3135
3236# Scale green channel
3337print ("scale green channel (note: masked)" )
34- b = decode_blinka ( 3 )
38+ b = test_pattern ( )
3539bitmapfilter .mix (b , [1 , 2 , 0 ], mask = q )
3640dump_bitmap_rgb_swapped (b )
3741
38- # Swap R & G channels, invert B channel
39- print ("swap R&G, invert B" )
40- b = decode_blinka (3 )
41- bitmapfilter .mix (b , [0 , 1 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , - 1 , 1 ])
42+ # Swap R & G channels
43+ print ("swap R&G" )
44+ b = test_pattern ()
45+ bitmapfilter .mix (b , [0 , 1 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ])
46+ dump_bitmap_rgb_swapped (b )
47+
48+ # invert B
49+ print ("invert B" )
50+ b = test_pattern ()
51+ bitmapfilter .mix (b , [1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , - 1 , 1 ])
4252dump_bitmap_rgb_swapped (b )
0 commit comments