MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__vertical_flip

Function stbi__vertical_flip

Source/Utils/stb_image.h:1221–1243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1219}
1220
1221static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel)
1222{
1223 int row;
1224 size_t bytes_per_row = (size_t)w * bytes_per_pixel;
1225 stbi_uc temp[2048];
1226 stbi_uc *bytes = (stbi_uc *)image;
1227
1228 for (row = 0; row < (h>>1); row++) {
1229 stbi_uc *row0 = bytes + row*bytes_per_row;
1230 stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row;
1231 // swap row0 with row1
1232 size_t bytes_left = bytes_per_row;
1233 while (bytes_left) {
1234 size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp);
1235 memcpy(temp, row0, bytes_copy);
1236 memcpy(row0, row1, bytes_copy);
1237 memcpy(row1, temp, bytes_copy);
1238 row0 += bytes_copy;
1239 row1 += bytes_copy;
1240 bytes_left -= bytes_copy;
1241 }
1242 }
1243}
1244
1245#ifndef STBI_NO_GIF
1246static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel)

Calls

no outgoing calls

Tested by

no test coverage detected