MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / writeImage

Function writeImage

TheForceEngine/TFE_Asset/imageAsset.cpp:161–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 5

writeGpuTextureAsPngFunction · 0.85
debug_writeOutAtlasFunction · 0.85
generateTrueColorMappingFunction · 0.85
console_exportTextureFunction · 0.85
writeFramesToDiskMethod · 0.85

Calls 2

flipImageFunction · 0.85
logWriteFunction · 0.85

Tested by

no test coverage detected