| 1241 | } |
| 1242 | |
| 1243 | static 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 |
| 1267 | static void stbi__vertical_flip_slices( |
no outgoing calls
no test coverage detected