Where a useful hint is given.Norman Radder wrote:Also posted at: http://www.dreamincode.net/forums/topic/400727-pick-rgb-value-and-play-sounds-accordingly-using-java/
Karael Asahi wrote:Ok, i keep that in mind for the next time, I'm really sorry. I'll to tell the other forum about this post too, then.
Right now I'm slowly checking and working on what everybody gently told me. I found something, as the person in the other forum suggested, regarding java.awt.image.BufferedImage.
Karael Asahi wrote:Hello again! In these days I tried to follow all your advices and found something more easy to me to understand and here what I got until now:
I used the first code to find the rgb values of each pixel, and the random one to make an average value, but it takes random values and not all of them... I can't figure out how to fix this. Also, I don't know yet how to associate the RGB values to the tracks.
Any other advice?
I am so sorry but I'm really new to java... thank you very much guys!
Campbell Ritchie wrote:Don't go round “trying” different code. You need to write down what you intend to do, then do it. I can see nothing wrong with your method to convert RGB to an int[]. What do you mean about random numbers? You are using a random number generator in line 51.
Write down what you intend to do with the image. Then show us it. I presume you have successfully imported the image, and you can access each pixel in the loop in line 33. In which case, print the RGB value of each pixel, and have a cup of coffee while that printout finishes. If that works, then consider how to get the red value out of that pixel. Also calculate how many pixels you can add before you suffer an arithmetic overflow, remembering the maximum value of red is 0xff and the maximum value of an int is 0x7fff_ffff.
What does line 37 do? I can't understand it, but I don't think it is correct.