user2615415
user2615415

Reputation: 1

How to read data from buffer selectively

I have an 720x576 picture saved row by row in an unsigned char luma[414720] and I need to display a centered picture with size 640x480.

My question is: What is the most efficient way to selectively access to the data saved in one buffer using just one for cycle?

Thanks for your answers.

Petr Duga

Upvotes: 0

Views: 94

Answers (1)

Jerry_Y
Jerry_Y

Reputation: 1734

Try this:

newLuma is the new pic to be displayed.

int i= 0;
char newLuma[640*480];
int rowStart = (576 - 480)/2 -1 ;
int colStart = (720 - 640)/2 -1 ;


for ( i = 0; i < 480; i++)
{
    memcpy(newLuma[i*640], luma[720*(rowStart + i) + colStart], 640);
}

Upvotes: 2

Related Questions