File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Two dimensional array problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Two dimensional array problem" Watch "Two dimensional array problem" New topic

Two dimensional array problem

Joshua Waring

Joined: Sep 04, 2012
Posts: 13

I have no idea what the problem is, I'm trying to read an image and place the colour inside an array which I'll use as a height map later, but right now... How to get pixel colour into a two dimensional array.
Richard Tookey

Joined: Aug 27, 2012
Posts: 1166

Do we have to guess what the symptoms of the problem are or are you willing to share them?
Kemal Sokolovic

Joined: Jun 19, 2010
Posts: 825

Your for loop conditions are not correct. You are trying to set WIDTH + 1 and HEIGHT + 1 element, but you only have WIDTH and HEIGHT of them in your arrays.

The quieter you are, the more you are able to hear.
Joshua Waring

Joined: Sep 04, 2012
Posts: 13
My silly mistake an array of 10 index's starts at 0 and ends at 9
I was going from 0 to one higher than the arrays length.

And the error was a arrayoutofbound
I agree. Here's the link:
subject: Two dimensional array problem
jQuery in Action, 3rd edition