MCPcopy Create free account
hub / github.com/SpartanJ/eepp / saveToFile

Method saveToFile

src/eepp/graphics/image.cpp:1169–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1167}
1168
1169bool Image::saveToFile( const std::string& filepath, const SaveType& Format ) {
1170 bool Res = false;
1171
1172 std::string fpath( FileSystem::fileRemoveFileName( filepath ) );
1173
1174 if ( !FileSystem::isDirectory( fpath ) )
1175 FileSystem::makeDir( fpath );
1176
1177 if ( NULL != mPixels && 0 != mWidth && 0 != mHeight && 0 != mChannels ) {
1178 if ( SaveType::WEBP == Format ) {
1179 auto data = webpPacker( *this, mFormatConfiguration.webpSaveQuality(),
1180 mFormatConfiguration.webpSaveLossless(),
1181 mFormatConfiguration.webpCompressionMethod() );
1182 if ( !data.empty() )
1183 FileSystem::fileWrite( filepath, data );
1184 } else if ( SaveType::JPG != Format ) {
1185 Res = 0 != ( SOIL_save_image( filepath.c_str(), (int)Format, (Int32)mWidth,
1186 (Int32)mHeight, mChannels, getPixelsPtr() ) );
1187 } else {
1188 jpge::params params;
1189 params.m_quality = mFormatConfiguration.jpegSaveQuality();
1190 Res = jpge::compress_image_to_jpeg_file( filepath.c_str(), mWidth, mHeight, mChannels,
1191 getPixelsPtr(), params );
1192 }
1193 }
1194
1195 return Res;
1196}
1197
1198void Image::replaceColor( const Color& ColorKey, const Color& NewColor ) {
1199 unsigned int Pos = 0;

Callers 4

takeScreenshotMethod · 0.45
updateTextureAtlasMethod · 0.45
saveMethod · 0.45
compareImagesFunction · 0.45

Calls 7

webpPackerFunction · 0.85
webpSaveQualityMethod · 0.80
webpSaveLosslessMethod · 0.80
webpCompressionMethodMethod · 0.80
c_strMethod · 0.80
jpegSaveQualityMethod · 0.80
emptyMethod · 0.45

Tested by 1

compareImagesFunction · 0.36