Shifting an image down a row
I've been given someone elses code and I'm required to use their code and write new code in order to shift an image down a row....and later on, be able to shift the image back up a row. I'm pretty lost in their code and don't know exactly where to begin. Some image properties that I've been given with their code are:
Code:
ip.image_buffer = (unsigned char *) options->image_origin;
ip.image_size.cx = options->image_width;
ip.image_size.cy = options->image_height;
ip.image_pitch = options->image_line_delta;
ip.y_mask = 0xffffffff;
ip.x_min = 0;
ip.x_max = ip.image_size.cx - 1;
ip.y_min = 0;
ip.y_max = ip.image_size.cy - 1;
ip.num_pixels = ip.image_pitch * ip.image_size.cy;
ip.bounded_frame = 1;
ip.linear = 1;
and here is part of a method that might be useful...but I'm not too sure yet:
int row, col;
unsigned char min;
unsigned char *out_ptr;
unsigned char *row_n1, *row_0, *row_p1;
unsigned char col_min_n1, col_min_0, col_min_p1;
ia_get_image_params(&ip);
for(row = 1; row < ip.image_size.cy - 1; row++)
{
out_ptr = &ip.image_buffer[row * ip.image_size.cx + 1];
row_n1 = &ip.original_image_buffer[(row-1) * ip.image_size.cx];
row_0 = row_n1 + ip.image_size.cx;
row_p1 = row_0 + ip.image_size.cx;
for(col = 1; col < ip.image_size.cx - 1; col++)
{
min = col_min_n1;
if (col_min_0 < min) min = col_min_0;
if (col_min_p1 < min) min = col_min_p1;
*out_ptr++ = min;
col_min_n1 = col_min_0;
col_min_0 = col_min_p1;
}
}
I've been told that ip.image_buffer is the start of the image. That's about all the info I've been given and I'm not too sure I have enough to complete this task, but any help in the right direction is appreciated. Thanks