backport GetGrayLevel close Pull Request #25

Signed-off-by: hennors <e-fowl@gmx.de>