mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Support for loading from memory
This commit is contained in:
parent
1cb5538317
commit
f51b195486
1 changed files with 19 additions and 3 deletions
|
@ -133,10 +133,26 @@ Texture* RenderDevice::LoadTexture(const StringImpl& fileName, int flags)
|
|||
if (!handled)
|
||||
{
|
||||
imageData->mWantsAlphaPremultiplied = (flags & TextureFlag_NoPremult) == 0;
|
||||
if (!imageData->LoadFromFile(fileName))
|
||||
if (fileName.StartsWith("@"))
|
||||
{
|
||||
failed = true;
|
||||
BF_FATAL("Failed to load image");
|
||||
int colon = (int)fileName.IndexOf(':');
|
||||
String addrStr = fileName.Substring(1, colon - 1);
|
||||
String lenStr = fileName.Substring(colon + 1);
|
||||
void* addr = (void*)(intptr)strtoll(addrStr.c_str(), NULL, 16);
|
||||
int len = (int)strtol(lenStr.c_str(), NULL, 10);
|
||||
if (!imageData->LoadFromMemory(addr, len))
|
||||
{
|
||||
failed = true;
|
||||
BF_FATAL("Failed to load image");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!imageData->LoadFromFile(fileName))
|
||||
{
|
||||
failed = true;
|
||||
BF_FATAL("Failed to load image");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue