<< Chapter < Page | Chapter >> Page > |
You can download a copy of the raw image file here .
In this module, you learned how to invert images and how to display images in PictureExplorer objects.
You will learn how to implement a space-wise linear color-modification algorithm in the next module.
While not a requirement of the course, you can select the following links to view optional online video lectures on the material in thismodule.
This section contains a variety of miscellaneous information.
Financial : Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.
I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.
In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. Ineither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please beaware that it is a copy of a module that is freely available on cnx.org and that it was made and published withoutmy prior knowledge.
Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.
A complete listing of the program discussed in this module is shown in Listing 6 below.
Listing 6 . Complete program listing. |
---|
/*File Prob02 Copyright 2008 R.G.Baldwin
*********************************************************/public class Prob02{//the driver class
public static void main(String[]args){
Prob02Runner obj = new Prob02Runner();obj.run();
System.out.println(obj.getPicture());}//end main
}//end class Prob02//======================================================//
class Prob02Runner{private Picture pic = new Picture("Prob02.jpg");
public Prob02Runner(){//constructorSystem.out.println("Dick Baldwin");
}//end constructor//----------------------------------------------------//
//Accessor methodpublic Picture getPicture(){return pic;}
//----------------------------------------------------////This method is where the action is.
public void run(){//Display the raw picture.
pic.addMessage("Dick Baldwin",10,20);pic.explore();
//Set the blue color components to 0 and invert the// red and green color components for every pixel in
// the picture.Pixel[] pixelArray = pic.getPixels();for(Pixel pixel:pixelArray ){
pixel.setRed(255 - pixel.getRed());pixel.setGreen(255 - pixel.getGreen());
pixel.setBlue(0);}//end for loop
//Display the modified picturepic.explore();
}//end run method}//end class Prob02Runner |
-end-
Notification Switch
Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?