This used to be rather cryptic and it was easy to forget the `+ 1` which in fact is needed to get the correct width/height, see e626998a26. This should also fix some minor off-by-one errors.
e626998a26