mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 17:28:11 +00:00
LibGfx: Add a new Bitmap::is_path_a_supported_image_format() method
Move the image file detection code to the File class to prevent code duplication.
This commit is contained in:
parent
17aa917073
commit
56158a4281
2 changed files with 20 additions and 5 deletions
|
@ -29,8 +29,8 @@
|
|||
#include <AK/SharedBuffer.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/PNGLoader.h>
|
||||
#include <LibGfx/GIFLoader.h>
|
||||
#include <LibGfx/PNGLoader.h>
|
||||
#include <LibGfx/ShareableBitmap.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -86,10 +86,11 @@ RefPtr<Bitmap> Bitmap::create_wrapper(BitmapFormat format, const IntSize& size,
|
|||
|
||||
RefPtr<Bitmap> Bitmap::load_from_file(const StringView& path)
|
||||
{
|
||||
if(path.ends_with(".png"))
|
||||
return load_png(path);
|
||||
if(path.ends_with(".gif"))
|
||||
return load_gif(path);
|
||||
#define __ENUMERATE_IMAGE_FORMAT(Name, Ext) \
|
||||
if (path.ends_with(Ext)) \
|
||||
return load_##Name(path);
|
||||
ENUMERATE_IMAGE_FORMATS
|
||||
#undef __ENUMERATE_IMAGE_FORMAT
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue