im working on this assignment and for some reason its not copying all the rows. It skips certain lines of the bmp so it does not enlarge the picture entirely. I would greatly appreciate some feedback as to why its doing this. I know it's got to be related with the pointer arithmetic.
int enlarge(PIXEL* original, int rows, int cols, int scale,
PIXEL** new, int* newrows, int* newcols)
{
*newcols = cols * scale;
*newrows = rows * scale;
/* Allocate memory for enlarged bmp */
*new = (PIXEL*)malloc( (*newrows)*(*newcols) * sizeof(PIXEL));
if(!*new)
{
free(*new);
fprintf(stderr, "Could not allocate memory.\n");
return 1;
}
int i,j,k,l;
int index = 0;
int counter = scale*rows;
PIXEL* o;
PIXEL* n;
for(i = 0; i < rows; i++)
{
for(j = 0; j < cols; j++)
{
for(k = 0; k < scale; k++)
{
o = original + (i*cols) + j;
index++;
for(l = 0; l < scale; l++)
{
n = (*new) + ( i*cols*scale ) + index + (counter*l);
*n = *o;
}
}
}
}
return 0;
}