I was working on a project but I got stuck. I wanted to show 2 rows of picture with 3 column. But when ever I change the number for colume, it only create blank white space and no image there. The first row works fine. How can if fix this?


Below are my code


/**
test file
*/

// import statements - tells the Java Compiler what special libraries we are using
import java.awt.Color;

// Note the name of the class in the following line MUST
// match the name of the file.
public class test
{

public static void main (String[] args)
{
String filename = FileChooser.pickAFile ();
Picture original = new Picture ( filename );

Picture modified;
modified = manipulate (original);

modified.show ();
}

//method
public static Picture manipulate ( Picture p1 )
{
int repeatCount = 3;
int rowCount=2;

int width = p1.getWidth();
int height = p1.getHeight();

/* this is where it give me the problem. I can make the first row show up but not the second. it suppose to look like = , instead I have -.


if I multiply 3 * height, it create blank white space and not the picture.

*/
Picture p2 = new Picture ( (repeatCount*width) ,(int)2*height);

int xPos, yPos;

Color c1, c2, c3, c4;

for ( xPos = 0 ; xPos < width ; xPos ++ )
{
for ( yPos = 0 ; yPos < height ; yPos ++ )
{
Pixel pix1, pix2;
int modifiedX;
int modifiedY;

pix1 = p1.getPixel (xPos, yPos);
c1 = pix1.getColor ();

int index;
for ( index = 0 ; index < repeatCount ; ++index )
{
// store original information into the same position on "copy"
modifiedX = (index * width) + xPos;
pix2 = p2.getPixel (modifiedX, yPos);

if ( index == 1)
{
c2 = modifyColor2 ( c1 );
}
else if (index == 2)
{
c2 = modifyColor1 ( c1 );
}
else
{
c2 = c1;
}

pix2.setColor ( c2 );
}

}
}
return p2;
} // end of method











public static Color modifyColor1 (Color c)
{
int red, green, blue;
red = c.getRed();
green = c.getGreen();
blue = c.getBlue();

return new Color (green, blue, red);
}


public static Color modifyColor2 (Color c)
{
int red, green, blue;
red = c.getRed();
green = c.getGreen();
blue = c.getBlue();

return new Color (255 - red, 255 - green, 255 - blue);
}
} // end of class