Fix contrast percentage handling, fixes #1144