The API documentation for BufferedImage.setRGB explains why getRGB might give you a different value from the one you supply in setRGB. Could that apply in your case?