Ask Your Question

Revision history [back]

RGB changing B value affects R and G as well.... How to solve?

I am creating a 100x100 BufferedImage, if I set R=200, G=160, B=80.. SetRGB and Write to disc using ImageIO.write, I am getting a Solid Color image alright. I can also Get the Pixel Values of the Created Image from another function without any error.

Now, I am creating another Image with the same procedure, this time I am keeping R=200, G=160.. same as above, not disturbing. But I am changing the value of blue with an integer array, say (156, 145, 24.......). I expect an Image With Red and Green Constant as the previous Image, different values for Blue. But Using my reader function to GetPixels, I have 2 problems i) Blue, is NOT retrieving the Values that I set ii) Instead being constant, R and G values are also some random(?) numbers.. (The Writer or Reader functions do not throw any errors). I am working with Java, OpenCV 2+ version, Netbeans. Any Idea what could be wrong? Thanks in advance.