Throw an exception when creating bitmaps with invalid dimensions.

Closes #1197.