Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review-Fall 2007: Posterize

Back to Midterm Exam 1 Review-Fall 2007
Ask your questions here...


Question: Would I have to do anything besides change the conditions inside the if statements for the first question? On a test would we have to do a while loop since you gave a for loop?

 public void newPosterize(){
  Pixel pixel = null;
  int redValue = 0;
  int greenValue = 0;
  int blueValue = 0;
  
  for (int x = 0; x< this.getWidth(); x++){
    for (int y=0 ; y< this.getHeight(); y++){
      
      pixel = this.getPixel(x,y);
      redValue = pixel.getRed();
      greenValue=pixel.getGreen();
      blueValue = pixel.getBlue();
      
      if (redValue < 128 )
        redValue = 255;
      else if (redValue <= 128)
        redValue = 5;
      
      if (greenValue < 10)
        greenValue = 200;
      else if (greenValue >200)
        greenValue = 10;
      
      if (blueValue <= 250)
        blueValue = 200;
      else if (blueValue > 250)
        blueValue = 201;
      
      pixel.setRed(redValue);
      pixel.setGreen(greenValue);
      pixel.setBlue(blueValue);
    }
  }
}





Link to this Page