File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -97,13 +97,15 @@ def apply_mask(self, image):
9797 # black and white, so if these are also our mask colors we don't
9898 # need to do anything. This is much faster than actually applying a
9999 # mask.
100- pass
101- else :
102- # TODO there's probably a way to use PIL.ImageMath instead of doing
103- # the individual pixel comparisons that the base class uses, which
104- # would be a lot faster. (In fact doing this would probably remove
105- # the need for the B&W optimization above.)
106- QRColorMask .apply_mask (self , image )
100+ return
101+
102+ image .paste (
103+ Image .composite (
104+ Image .new ("RGB" , image .size , self .front_color ),
105+ Image .new ("RGB" , image .size , self .back_color ),
106+ image .convert ("L" ).point (lambda p : 255 if p < 128 else 0 ),
107+ )
108+ )
107109
108110 def get_fg_pixel (self , image , x , y ):
109111 return self .front_color
You can’t perform that action at this time.
0 commit comments