Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two dimensional array problem

 
Joshua Waring
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do we have to guess what the symptoms of the problem are or are you willing to share them?
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joshua Waring
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic