Modification of the SimplePicture class (cont'd)

Note the change shown in boldface in Listing 1.

(There are probably other ways that you can modify the class to achieve the same result as well.)

Listing 1. Modification of the SimplePicture class.
 /**
  * A constructor that takes the 
  * width and height desired
  * for a picture and creates a 
  * buffered image of that
  * size.  This constructor 
  * doesn't show the picture.
  */
 public  SimplePicture(int width, int height){
//Disable the following statement
//   bufferedImage = new BufferedImage(
//       width, height, BufferedImage.TYPE_INT_RGB);

   //Modify to support alpha transparency.
   bufferedImage = new BufferedImage(
        width, height, BufferedImage.TYPE_INT_ARGB);
             
   title = "None";
   fileName = "None";
   extension = "jpg";
   setAllPixelsToAColor(Color.white);
 }//end constructor
File: ax.htm [Next] [Prev]