Basically part of my project was to take the rows of pixels from a picture and make each row display twice, and the same for the column, and then eventually do them both together. However, I am having trouble with my loop to duplicate the rows or column. What I think is happenin in my code is the its just skipping a line instead of duplicating it, but im not sure. Ive spent hours on this and am truly stuck. any help is appreciated.

public static Photograph stretched(Photograph photo, int type) {

height = photo.getHeight();
width= photo.getWidth();

if(type == 0){
Photograph fat = new Photograph(2*width,height);
fat(width,height,fat,photo);
return fat;
}else{

Photograph tall = new Photograph(width, 2*height);
tall(width,height,tall,photo);
return tall;
}

}
private static Photograph fat(int width,int height, Photograph brandnew,
Photograph original){

for(int c = 0; c < height; c++){
int test =2, mark = 0;

for(int d = 0; d < width; d++){
Pixel a = original.getPixel(d,c);

while(mark < test){

brandnew.setPixel(d+mark, c, a);
mark++;
}
test++;
}

}
return brandnew;
}

private static void tall(int width,int height, Photograph brandnew,
Photograph original){

int mark = 0, test =2;
for(int c = 0; c < height; c++){

while(mark < test){
for(int d = 0; d < width; d++){
Pixel a = original.getPixel(d,c);
brandnew.setPixel(d, c+mark, a);

}
mark++;
}
test++;
}

}


The idea is to go through each pixel once, but work on filling into the pixel 4 times. In other words, you are enlarging it 4 times bigger than its original. It is difficult to explain in word, so I a'm going to show you how to do it with a 2D integer array instead.

/*
A simple diagram is below.

from 1x1     to 2x2
+----+       +----+----+
| v1 |   --> | v1 | v1 |  row2  (1x2)
+----+       +----+----+
| v1 | v1 |  row3  (1x2 + 1)
original     +----+----+
index at     col4   col5
row1         (2x2) (2x2 + 1)
col2
*/

//i.e.
// first prepare original array & dup array
int[][] oriArr = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};  // 2D array of 3x4
int[][] dupArr = new int[oriArr.length*2][oriArr[0].length*2]; // 6x8

// then I'm going to go through each original array item
// while duplicating it into 4
int dblRow, dblCol;
for (int row=0; row<oriArr.length; row++) {
// need to keep the double value of the row
// think that each row will be at the 2x index position
dblRow = row*2;
for (int col=0; col<oriArr[row].length; col++) {
// need to keep the double value of column as well
dblCol = col*2;
// now do it 4 times
dupArr[dblRow][dblCol] = oriArr[row][col];     // top-left cell     (row 2x, column 2x)
dupArr[dblRow+1][dblCol] = oriArr[row][col];   // bottom-left cell  (row 2x+1, column 2x)
dupArr[dblRow][dblCol+1] = oriArr[row][col];   // top-right cell    (row 2x, column 2x+1)
dupArr[dblRow+1][dblCol+1] = oriArr[row][col]; // bottom-right cell (row 2x+1, column 2x+1)
}  // end each column
}  // end each row


It is not exactly the solution to your question, but this is exactly the approach you need to do because you would need to break it down into row & column instead of do both at the same time as I show you. If you still don't get the idea, please ask.