File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Array problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array problems" Watch "Array problems" New topic
Author

Array problems

james falk
Ranch Hand

Joined: Nov 02, 2012
Posts: 55
Hey all,

I am having some trouble with an array. I am wondering how I initialize a 2d array with values? For instance, if I want to create a 2d array with values 1-10 in each of the arrays, how do i do that?

Here's what I tried:

But this gave me wonky results...

Any thoughts?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
You can't just work on the values of the pixels directly - those contain the values of R, G, and B all in one pixel. You need to do the averaging separately for the R, G and B components of each pixel. Something like


Ping & DNS - my free Android networking tools app
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41104
    
  45
Um, did you just edit your post all out of context?
james falk
Ranch Hand

Joined: Nov 02, 2012
Posts: 55
Yeah, sorry about that. I figured out what I was doing wrong, had another question, and thought I could edit it before anyone responded. Sorry for the confusion. Thanks for the help btw.
 
wood burning stoves
 
subject: Array problems
 
Similar Threads
Picture Manipulation Methods
Logical operation on Image
Setting java.awt.Image background color
Array of Objects
BufferedImage and scanning pixels