Skip to content

Instantly share code, notes, and snippets.

@ZOulhadj
Created July 9, 2024 21:48
Show Gist options
  • Save ZOulhadj/a977be53cafafe1ef72908bb0da0b1e0 to your computer and use it in GitHub Desktop.
Save ZOulhadj/a977be53cafafe1ef72908bb0da0b1e0 to your computer and use it in GitHub Desktop.
Rectangle copy
static void copy_rect(char* buffer_src, int pitch_a,
char* buffer_dst, int pitch_b,
int from_min_x, int from_min_y,
int from_max_x, int from_max_y,
int to_min_x, int to_min_y)
{
char* src = buffer_src + from_min_y * pitch_a + from_min_x;
char* dst = buffer_dst + to_min_y * pitch_b + to_min_x;
int width = from_max_x - from_min_x;
int height = from_max_y - from_min_y;
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
dst[x] = src[x];
}
src += pitch_a;
dst += pitch_b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment