public boolean ManipBoxPattern(int xMin, int yMin, int xMax, int yMax, double amount) { int x; int y; y = yMin; while (y < yMax) { x = xMin; while (x < xMax) { Pixel p = this.getPixel(x, y); int yOffset = Math.abs(yMin - y); int xOffset = Math.abs(xMin - x); double ra = normal(x, xMin, xMax); if (ra >= 1.0) { int R = (int) (p.getRed() * amount); int G = (int) (p.getGreen() * amount); int B = (int) (255 * amount); p.setRed(R); p.setGreen(G); p.setBlue(B); p.getColor().brighter(); } else { int R = (int) (p.getRed() * amount); int G = (int) (255 * amount); int B = (int) (p.getBlue() * amount); p.setRed(R); p.setGreen(G); p.setBlue(B); } if (x % 2 == 0) { int R = (int) (255 * amount); int G = (int) (p.getGreen() * amount); int B = (int) (p.getBlue() * amount); p.setRed(R); p.setGreen(G); p.setBlue(B); } x = x + 1; } y = y + 1; } return true; }
public void negate() { Pixel[][] pixels = this.getPixels2D(); for (Pixel[] rowArray : pixels) { for (Pixel pixelObj : rowArray) { pixelObj.setRed(255 - pixelObj.getRed()); pixelObj.setGreen(255 - pixelObj.getGreen()); pixelObj.setBlue(255 - pixelObj.getBlue()); } } }
public void grayscale() { Pixel[][] pixels = this.getPixels2D(); for (Pixel[] rowArray : pixels) { for (Pixel pixelObj : rowArray) { int ave = (pixelObj.getRed() + pixelObj.getGreen() + pixelObj.getBlue()) / 3; pixelObj.setBlue(ave); pixelObj.setRed(ave); pixelObj.setGreen(ave); } } }
public void negate() { Pixel[][] pixels = this.getPixels2D(); for (Pixel[] rowArray : pixels) { for (Pixel pixelObj : rowArray) { int a = pixelObj.getRed(); int b = pixelObj.getBlue(); int c = pixelObj.getGreen(); pixelObj.setRed(255 - a); pixelObj.setBlue(255 - b); pixelObj.setGreen(255 - c); } } }
/* ****************** CHECKLIST ****************************** [x] change the colors within the box specified by the parameters [x] the new Color in each Pixel MUST depend BOTH (a) on that particular Pixel's previous Color and (b) on the value of the amount parameter */ public boolean ManipBoxUniformly(int xMin, int yMin, int xMax, int yMax, double amount) { for (int x = xMin; x < xMax - 1; x++) { for (int y = yMin; y < yMax - 1; y++) { amount -= 0.0000001; if (amount < 0.1) amount = 0.2; Pixel p = this.getPixel(x, y); int B = (int) (p.getGreen() * (amount)); p.setGreen(B); } } return true; }
public void greyscale() { Pixel[][] pixels = this.getPixels2D(); for (Pixel[] rowArray : pixels) { for (Pixel pixelObj : rowArray) { int a = pixelObj.getRed(); int b = pixelObj.getBlue(); int c = pixelObj.getGreen(); int d = (a + b + c) / 3; pixelObj.setRed(d); pixelObj.setBlue(d); pixelObj.setGreen(d); } } }