From 72c4451ebed74a7d9f3d959e00da1c6e94dfe57e Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 8 Apr 2025 20:36:29 +0200 Subject: [PATCH] disable some more sdl image file types, and use typed loaders --- src/image_loader_sdl_image.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/image_loader_sdl_image.cpp b/src/image_loader_sdl_image.cpp index c837eb4..37a2caa 100644 --- a/src/image_loader_sdl_image.cpp +++ b/src/image_loader_sdl_image.cpp @@ -6,6 +6,11 @@ #include static std::optional getExt(SDL_IOStream* ios) { + // blacklist: + // - tga + // - tiff + // - xcf + if (IMG_isAVIF(ios)) { return "avif"; } else if (IMG_isCUR(ios)) { @@ -30,10 +35,6 @@ static std::optional getExt(SDL_IOStream* ios) { return "pnm"; } else if (IMG_isSVG(ios)) { return "svg"; - } else if (IMG_isTIF(ios)) { - return "tiff"; - } else if (IMG_isXCF(ios)) { - return "xcf"; } else if (IMG_isXPM(ios)) { return "xpm"; } else if (IMG_isXV(ios)) { @@ -52,14 +53,13 @@ ImageLoaderSDLImage::ImageInfo ImageLoaderSDLImage::loadInfoFromMemory(const uin auto* ios = SDL_IOFromConstMem(data, data_size); - // we ignore tga auto ext_opt = getExt(ios); if (!ext_opt.has_value()) { SDL_CloseIO(ios); return res; } - SDL_Surface* surf = IMG_Load_IO(ios, true); + SDL_Surface* surf = IMG_LoadTyped_IO(ios, true, ext_opt.value()); if (surf == nullptr) { return res; } @@ -78,14 +78,13 @@ ImageLoaderSDLImage::ImageResult ImageLoaderSDLImage::loadFromMemoryRGBA(const u auto* ios = SDL_IOFromConstMem(data, data_size); - // we ignore tga auto ext_opt = getExt(ios); if (!ext_opt.has_value()) { SDL_CloseIO(ios); return res; } - IMG_Animation* anim = IMG_LoadAnimation_IO(ios, true); + IMG_Animation* anim = IMG_LoadAnimationTyped_IO(ios, true, ext_opt.value()); if (anim == nullptr) { return res; }