bring ImageColor.getcolor into line with Convert.c implementation

This commit is contained in:
Alexander 2019-12-31 16:56:09 +03:00
parent fa1deca144
commit 038f9daf27

View File

@ -134,7 +134,9 @@ def getcolor(color, mode):
if Image.getmodebase(mode) == "L": if Image.getmodebase(mode) == "L":
r, g, b = color r, g, b = color
color = (r * 299 + g * 587 + b * 114 + 500) // 1000 # ITU-R Recommendation 601-2 for nonlinear RGB
# scaled to 24 bits to match the convert's implementation.
color = (r * 19595 + g * 38470 + b * 7471 + 0x8000) >> 16
if mode[-1] == "A": if mode[-1] == "A":
return (color, alpha) return (color, alpha)
else: else: