| 159 | } |
| 160 | |
| 161 | void writeImage(const char* path, u32 width, u32 height, u32* pixelData) |
| 162 | { |
| 163 | // TODO: This seems to be specific to the PBO/capture path, so the flip should really happen there. |
| 164 | u32* writeBuffer = flipImage(pixelData, width, height); |
| 165 | |
| 166 | SDL_Surface* surf = SDL_CreateRGBSurfaceFrom(writeBuffer, width, height, |
| 167 | 32, width * sizeof(u32), |
| 168 | 0xFF, 0xFF00, 0xFF0000, 0xFF000000); |
| 169 | if (!surf) |
| 170 | { |
| 171 | TFE_System::logWrite(LOG_ERROR, "writeImage", "Saving PNG '%s' - cannot allocate surface", path); |
| 172 | return; |
| 173 | } |
| 174 | if (IMG_SavePNG(surf, path) != 0) |
| 175 | { |
| 176 | TFE_System::logWrite(LOG_ERROR, "writeImage", "Saving PNG '%s' failed with '%s'", path, SDL_GetError()); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | ////////////////////////////////////////////////////// |
| 181 | // Wacky file override to get SDL-Image to write |
no test coverage detected