java - Displaying RGB numbers of an image -
i need display of rgb numbers each pixel in chosen picture, each number separated space, , use println (break) after every row of picture. i've figured out , written code return of rgb numbers, don't know how break after each row. here code far..
public void getcolor() { system.out.println("this picture's dimensions are: "+this.getwidth()+" "+this.getheight()); (int row=0; row < this.getheight(); row++) // gives number of rows { (int col=0; col < this.getwidth(); col++)// gives 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
you'd need put line break outside of innermost loop because want run after each row done.
public void getcolor() { system.out.println("this picture's dimensions are: "+this.getwidth()+" "+this.getheight()); (int row=0; row < this.getheight(); row++) // gives number of rows { (int col=0; col < this.getwidth(); col++)// gives number of columns { pixel pix = this.getpixel(col,row); system.out.print(pix.getred()+" "+pix.getgreen()+" "+pix.getblue()+" "); } // end of inner loop //after ^^^ loop runs, you've gone on whole row. system.out.println(); }// end of outer loop } // end of method
Comments
Post a Comment