mardi 31 mars 2015

Displaying RGB numbers of an image

I need to display all of the RGB numbers for each pixel in a chosen picture, with each number separated by a space, and use println (break) after every row of the picture. I've figured out and written the code to return all of the RGB numbers, but I don't know how to break after each row. Here is my code so far..



public void getColor()
{
System.out.println("This picture's dimensions are: "+this.getWidth()+" by "+this.getHeight());
for (int row=0; row < this.getHeight(); row++) // gives the number of rows
{
for (int col=0; col < this.getWidth(); col++)// gives the number of columns
{
Pixel pix = this.getPixel(col,row);
System.out.print(pix.getRed()+" "+pix.getGreen()+" "+pix.getBlue()+" ");
} // end of inner loop
}// end of outer loop
} // end of method

Aucun commentaire:

Enregistrer un commentaire