mirror of
https://github.com/love2d/love.git
synced 2026-08-20 12:40:20 +02:00
Cleaned up the code for determining whether an image can be decoded using stb_image.
--HG-- branch : minor
This commit is contained in:
@@ -48,11 +48,14 @@ namespace magpie
|
|||||||
|
|
||||||
bool STBHandler::canDecode(love::filesystem::FileData *data)
|
bool STBHandler::canDecode(love::filesystem::FileData *data)
|
||||||
{
|
{
|
||||||
stbi__context s = {};
|
int w = 0;
|
||||||
stbi__start_mem(&s, (const stbi_uc *) data->getData(), (int) data->getSize());
|
int h = 0;
|
||||||
|
int comp = 0;
|
||||||
|
|
||||||
// These are internal stb_image functions, but we can still use them!
|
int status = stbi_info_from_memory((const stbi_uc *) data->getData(),
|
||||||
return stbi__bmp_test(&s) || stbi__tga_test(&s);
|
(int) data->getSize(), &w, &h, &comp);
|
||||||
|
|
||||||
|
return status == 1 && w > 0 && h > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool STBHandler::canEncode(ImageData::Format format)
|
bool STBHandler::canEncode(ImageData::Format format)
|
||||||
|
|||||||
Reference in New Issue
Block a user