Making a picture Warhol Style
I am trying to create a method so that in my Picture.java class that will create and return a new picture object, the new picture will be a grid layout with four versions of the picture. The four versions will be Grays, Reds, Blues, and Greens. Each version will contain the pixels that fit into that category, and there will be no overlap. It will look so the picture only has the pixels that are gray in the upper left hand corner, the picture of only the red pixels will be in the upper right hand corner, the picture with only the green pixels in the bottom left hand corner, and the reds the same way in the bottom right. The new picture will have twice the width and height, You need to see where each pixel belongs in order to know where to put them. Using an if/else if/else statement.
so far all I have gotten is this : I am stuck, and I am having two errors I am not sure about. Anything will help.
my errors are :
public Picture componentLayout()
//Declare new picture
Picture newPicture = new Picture(this.getWidth() * 2, this.getHeight()
Pixel sourcePixel = null;
Pixel targetPixel = null;
int targetX = 0;
int targetY = 0;
// the redvalue of each pixel in the image
// The bluevalue of each pixel in the image
int blueValue = 0;
// the greenvalue of each pixel in the image
Pixel pixelObj = null;
Pixel pixelArray = this.getPixels();
for (int index = 0; index < pixelArray.length; index++)
// Get the pixel at the current index from the array of pixels.
pixelObj = pixelArray[index];
// Get the blue value at the pixel.
blueValue = pixelObj.getBlue();
// Get the red value at the pixel.
redValue = pixelObj.getRed();
// Get the green value at the pixel
greenValue = pixelObj.getGreen();
int range = 0;
//loops through x
for (int x= 0; x < this.getWidth(); x++)
//loops through y
for (int y = 0; y < this.getHeight(); y++)
//source pixels retrieved
sourcePixel = this.getPixel(x,y);
if (redValue > blueValue && greenValue)
targetPixel = this.getWidth()*2;
2 errors found:
File: C:\Documents and Settings\SEFCUMgr\My Documents\bookClasses\Picture.java [line: 115]
Error: C:\Documents and Settings\SEFCUMgr\My Documents\bookClasses\Picture.java:115: operator && cannot be applied to boolean,int
File: C:\Documents and Settings\SEFCUMgr\My Documents\bookClasses\Picture.java [line: 117]
Error: C:\Documents and Settings\SEFCUMgr\My Documents\bookClasses\Picture.java:117: incompatible types
found : int
THANKS IN ADVANCE!