MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__vertical_flip

Function stbi__vertical_flip

lite/example/cpp_example/mge/cv/stb_image.h:1243–1264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241}
1242
1243static void stbi__vertical_flip(void* image, int w, int h, int bytes_per_pixel) {
1244 int row;
1245 size_t bytes_per_row = (size_t)w * bytes_per_pixel;
1246 stbi_uc temp[2048];
1247 stbi_uc* bytes = (stbi_uc*)image;
1248
1249 for (row = 0; row < (h >> 1); row++) {
1250 stbi_uc* row0 = bytes + row * bytes_per_row;
1251 stbi_uc* row1 = bytes + (h - row - 1) * bytes_per_row;
1252 // swap row0 with row1
1253 size_t bytes_left = bytes_per_row;
1254 while (bytes_left) {
1255 size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp);
1256 memcpy(temp, row0, bytes_copy);
1257 memcpy(row0, row1, bytes_copy);
1258 memcpy(row1, temp, bytes_copy);
1259 row0 += bytes_copy;
1260 row1 += bytes_copy;
1261 bytes_left -= bytes_copy;
1262 }
1263 }
1264}
1265
1266#ifndef STBI_NO_GIF
1267static void stbi__vertical_flip_slices(

Calls

no outgoing calls

Tested by

no test coverage detected