MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / SavePNG

Method SavePNG

Source/Images/image_export.cpp:113–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void ImageExport::SavePNG(const char *file_path, unsigned char *data, unsigned long width, unsigned long height, unsigned short levels) {
114 std::vector<unsigned char> scaled_data;
115 ImageExport::ScaleImageUp(data, levels, &width, &height, &scaled_data);
116 CreateParentDirs(file_path);
117#ifdef _WIN32
118 createfile(file_path);
119 std::string short_path(file_path);
120 ShortenWindowsPath(short_path);
121 if (!stbi_write_png(short_path.c_str(), width, height, 3, scaled_data.data(), width * 4)) {
122 DisplayError("Error", "Problem exporting .png file");
123 }
124#else
125 if (!stbi_write_png(file_path, width, height, 3, scaled_data.data(), width * 4)) {
126 DisplayError("Error", "Problem exporting .png file");
127 }
128#endif
129}
130
131void ImageExport::SavePNGTransparent(const char *file_path, unsigned char *data, unsigned long width, unsigned long height, unsigned short levels) {
132 std::vector<unsigned char> scaled_data;

Callers

nothing calls this directly

Calls 7

CreateParentDirsFunction · 0.85
createfileFunction · 0.85
ShortenWindowsPathFunction · 0.85
stbi_write_pngFunction · 0.50
DisplayErrorFunction · 0.50
c_strMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected