@@ -398,6 +398,37 @@ def test_alpha_composite(self) -> None:
398398 assert img_colors is not None
399399 assert sorted (img_colors ) == expected_colors
400400
401+ def test_alpha_composite_la (self ) -> None :
402+ # Arrange
403+ expected_colors = sorted (
404+ [
405+ (3300 , (255 , 255 )),
406+ (1156 , (170 , 192 )),
407+ (1122 , (128 , 255 )),
408+ (1089 , (0 , 0 )),
409+ (1122 , (255 , 128 )),
410+ (1122 , (0 , 128 )),
411+ (1089 , (0 , 255 )),
412+ ]
413+ )
414+
415+ dst = Image .new ("LA" , size = (100 , 100 ), color = (0 , 255 ))
416+ draw = ImageDraw .Draw (dst )
417+ draw .rectangle ((0 , 33 , 100 , 66 ), fill = (0 , 128 ))
418+ draw .rectangle ((0 , 67 , 100 , 100 ), fill = (0 , 0 ))
419+ src = Image .new ("LA" , size = (100 , 100 ), color = (255 , 255 ))
420+ draw = ImageDraw .Draw (src )
421+ draw .rectangle ((33 , 0 , 66 , 100 ), fill = (255 , 128 ))
422+ draw .rectangle ((67 , 0 , 100 , 100 ), fill = (255 , 0 ))
423+
424+ # Act
425+ img = Image .alpha_composite (dst , src )
426+
427+ # Assert
428+ img_colors = img .getcolors ()
429+ assert img_colors is not None
430+ assert sorted (img_colors ) == expected_colors
431+
401432 def test_alpha_inplace (self ) -> None :
402433 src = Image .new ("RGBA" , (128 , 128 ), "blue" )
403434
0 commit comments