More defensive coding inside getRGB()