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

Method loadFromPack

src/eepp/graphics/image.cpp:1039–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1037}
1038
1039void Image::loadFromPack( Pack* Pack, const std::string& FilePackPath ) {
1040 if ( NULL != Pack && Pack->isOpen() && -1 != Pack->exists( FilePackPath ) ) {
1041 ScopedBuffer buffer;
1042
1043 Pack->extractFileToMemory( FilePackPath, buffer );
1044
1045 int w, h, c;
1046 Uint8* data = stbi_load_from_memory( buffer.get(), buffer.length(), &w, &h, &c, mChannels );
1047
1048 if ( NULL != data ) {
1049 mPixels = data;
1050 mWidth = (unsigned int)w;
1051 mHeight = (unsigned int)h;
1052
1053 if ( STBI_default == mChannels )
1054 mChannels = (unsigned int)c;
1055
1056 mSize = mWidth * mHeight * mChannels;
1057
1058 mLoadedFromStbi = true;
1059 } else if ( svg_test_from_memory( buffer.get(), buffer.length() ) ) {
1060 ScopedBuffer data( buffer.length() + 1 );
1061 memcpy( data.get(), buffer.get(), buffer.length() );
1062 data[buffer.length()] = '\0';
1063 svgLoad( nsvgParse( (char*)data.get(), "px", 96.0f, 0xFFFFFFFF ) );
1064 } else if ( webp_test_from_memory( buffer.get(), buffer.length() ) ) {
1065 webpLoad( buffer.get(), buffer.length() );
1066 } else {
1067 Log::error( "Failed to load image %s. Reason: %s", FilePackPath.c_str(),
1068 stbi_failure_reason() );
1069 }
1070 } else {
1071 Log::error( "Failed to load image %s from pack.", FilePackPath.c_str() );
1072 }
1073}
1074
1075void Image::setPixels( const Uint8* data ) {
1076 if ( data != NULL ) {

Callers 1

loadTexturesMethod · 0.45

Calls 9

svg_test_from_memoryFunction · 0.85
webp_test_from_memoryFunction · 0.85
errorFunction · 0.85
c_strMethod · 0.80
isOpenMethod · 0.45
existsMethod · 0.45
extractFileToMemoryMethod · 0.45
getMethod · 0.45
lengthMethod · 0.45

Tested by 1

loadTexturesMethod · 0.36