summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy <timmot@users.noreply.github.com>2021-09-07 21:13:29 +1000
committerAndreas Kling <kling@serenityos.org>2021-09-09 02:34:29 +0200
commitc966c325719673a411b793250b6247862e3b89de (patch)
tree5a10b136a4252c8414db78f5481436870fa4225c /Userland
parenteb5320023ad6d4746dd6abfa191ea2e016719077 (diff)
downloadserenity-c966c325719673a411b793250b6247862e3b89de.zip
LibGfx: Move common loader functionality to load from memory functions
This will share functionality between the load from path and load from memory functions.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGfx/BMPLoader.cpp9
-rw-r--r--Userland/Libraries/LibGfx/BMPLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/DDSLoader.cpp9
-rw-r--r--Userland/Libraries/LibGfx/DDSLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/GIFLoader.cpp10
-rw-r--r--Userland/Libraries/LibGfx/GIFLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/ICOLoader.cpp10
-rw-r--r--Userland/Libraries/LibGfx/ICOLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/JPGLoader.cpp10
-rw-r--r--Userland/Libraries/LibGfx/JPGLoader.h4
-rw-r--r--Userland/Libraries/LibGfx/PBMLoader.cpp7
-rw-r--r--Userland/Libraries/LibGfx/PBMLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/PGMLoader.cpp7
-rw-r--r--Userland/Libraries/LibGfx/PGMLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/PNGLoader.cpp9
-rw-r--r--Userland/Libraries/LibGfx/PNGLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/PPMLoader.cpp7
-rw-r--r--Userland/Libraries/LibGfx/PPMLoader.h3
-rw-r--r--Userland/Libraries/LibGfx/PortableImageLoaderCommon.h18
19 files changed, 54 insertions, 70 deletions
diff --git a/Userland/Libraries/LibGfx/BMPLoader.cpp b/Userland/Libraries/LibGfx/BMPLoader.cpp
index 17c690629d..4973622a0c 100644
--- a/Userland/Libraries/LibGfx/BMPLoader.cpp
+++ b/Userland/Libraries/LibGfx/BMPLoader.cpp
@@ -171,17 +171,14 @@ RefPtr<Gfx::Bitmap> load_bmp(String const& path)
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- auto bitmap = load_bmp_impl((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded BMP: {}", bitmap->size(), LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_bmp_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
-RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_bmp_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_bmp_impl(data, length);
if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded BMP: <memory>", bitmap->size()));
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded BMP: {}", bitmap->size(), mmap_name));
return bitmap;
}
diff --git a/Userland/Libraries/LibGfx/BMPLoader.h b/Userland/Libraries/LibGfx/BMPLoader.h
index c73e94857e..1503bc3680 100644
--- a/Userland/Libraries/LibGfx/BMPLoader.h
+++ b/Userland/Libraries/LibGfx/BMPLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_bmp(String const& path);
-RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_bmp_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct BMPLoadingContext;
diff --git a/Userland/Libraries/LibGfx/DDSLoader.cpp b/Userland/Libraries/LibGfx/DDSLoader.cpp
index 5bf294919e..430bcdeab3 100644
--- a/Userland/Libraries/LibGfx/DDSLoader.cpp
+++ b/Userland/Libraries/LibGfx/DDSLoader.cpp
@@ -957,17 +957,14 @@ RefPtr<Gfx::Bitmap> load_dds(String const& path)
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- auto bitmap = load_dds_impl((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded DDS: {}", bitmap->size(), LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_dds_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
-RefPtr<Gfx::Bitmap> load_dds_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_dds_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_dds_impl(data, length);
if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded DDS: <memory>", bitmap->size()));
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded DDS: {}", bitmap->size(), mmap_name));
return bitmap;
}
diff --git a/Userland/Libraries/LibGfx/DDSLoader.h b/Userland/Libraries/LibGfx/DDSLoader.h
index 4179a956d1..852f410473 100644
--- a/Userland/Libraries/LibGfx/DDSLoader.h
+++ b/Userland/Libraries/LibGfx/DDSLoader.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
@@ -233,7 +234,7 @@ struct DDSHeaderDXT10 {
};
RefPtr<Gfx::Bitmap> load_dds(String const& path);
-RefPtr<Gfx::Bitmap> load_dds_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_dds_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct DDSLoadingContext;
diff --git a/Userland/Libraries/LibGfx/GIFLoader.cpp b/Userland/Libraries/LibGfx/GIFLoader.cpp
index 679cc8f461..53d0772f6d 100644
--- a/Userland/Libraries/LibGfx/GIFLoader.cpp
+++ b/Userland/Libraries/LibGfx/GIFLoader.cpp
@@ -87,19 +87,15 @@ RefPtr<Gfx::Bitmap> load_gif(String const& path)
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- GIFImageDecoderPlugin gif_decoder((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- auto bitmap = gif_decoder.bitmap();
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded GIF: {}", bitmap->size(), LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_gif_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
-RefPtr<Gfx::Bitmap> load_gif_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_gif_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
GIFImageDecoderPlugin gif_decoder(data, length);
auto bitmap = gif_decoder.bitmap();
if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded GIF: <memory>", bitmap->size()));
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded GIF: {}", bitmap->size(), mmap_name));
return bitmap;
}
diff --git a/Userland/Libraries/LibGfx/GIFLoader.h b/Userland/Libraries/LibGfx/GIFLoader.h
index 2227294e46..07eb4d6286 100644
--- a/Userland/Libraries/LibGfx/GIFLoader.h
+++ b/Userland/Libraries/LibGfx/GIFLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_gif(String const& path);
-RefPtr<Gfx::Bitmap> load_gif_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_gif_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct GIFLoadingContext;
diff --git a/Userland/Libraries/LibGfx/ICOLoader.cpp b/Userland/Libraries/LibGfx/ICOLoader.cpp
index cc0ee6dc05..6102ea5898 100644
--- a/Userland/Libraries/LibGfx/ICOLoader.cpp
+++ b/Userland/Libraries/LibGfx/ICOLoader.cpp
@@ -96,19 +96,15 @@ RefPtr<Gfx::Bitmap> load_ico(const StringView& path)
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- ICOImageDecoderPlugin decoder((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- auto bitmap = decoder.bitmap();
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded ICO: {}", bitmap->size(), LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_ico_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
-RefPtr<Gfx::Bitmap> load_ico_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_ico_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
ICOImageDecoderPlugin decoder(data, length);
auto bitmap = decoder.bitmap();
if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded ICO: <memory>", bitmap->size()));
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded ICO: {}", bitmap->size(), mmap_name));
return bitmap;
}
diff --git a/Userland/Libraries/LibGfx/ICOLoader.h b/Userland/Libraries/LibGfx/ICOLoader.h
index f7fa88502a..3c0fd8ba3f 100644
--- a/Userland/Libraries/LibGfx/ICOLoader.h
+++ b/Userland/Libraries/LibGfx/ICOLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_ico(const StringView& path);
-RefPtr<Gfx::Bitmap> load_ico_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_ico_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct ICOLoadingContext;
diff --git a/Userland/Libraries/LibGfx/JPGLoader.cpp b/Userland/Libraries/LibGfx/JPGLoader.cpp
index 0169e03316..0784044bbe 100644
--- a/Userland/Libraries/LibGfx/JPGLoader.cpp
+++ b/Userland/Libraries/LibGfx/JPGLoader.cpp
@@ -9,7 +9,6 @@
#include <AK/Debug.h>
#include <AK/HashMap.h>
#include <AK/LexicalPath.h>
-#include <AK/MappedFile.h>
#include <AK/Math.h>
#include <AK/MemoryStream.h>
#include <AK/String.h>
@@ -1238,17 +1237,14 @@ RefPtr<Gfx::Bitmap> load_jpg(String const& path)
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- auto bitmap = load_jpg_impl((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded JPG: {}", bitmap->size(), LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_jpg_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), path);
}
-RefPtr<Gfx::Bitmap> load_jpg_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_jpg_impl(data, length);
if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded jpg: <memory>", bitmap->size()));
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded jpg: {}", bitmap->size(), mmap_name));
return bitmap;
}
diff --git a/Userland/Libraries/LibGfx/JPGLoader.h b/Userland/Libraries/LibGfx/JPGLoader.h
index 549eeee019..04741fa978 100644
--- a/Userland/Libraries/LibGfx/JPGLoader.h
+++ b/Userland/Libraries/LibGfx/JPGLoader.h
@@ -6,6 +6,8 @@
#pragma once
+#include <AK/MappedFile.h>
+#include <AK/String.h>
#include <AK/Vector.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
@@ -14,7 +16,7 @@
namespace Gfx {
RefPtr<Gfx::Bitmap> load_jpg(String const& path);
-RefPtr<Gfx::Bitmap> load_jpg_from_memory(const u8* data, size_t length);
+RefPtr<Gfx::Bitmap> load_jpg_from_memory(u8 const* data, size_t length, String const& mmap_name = "<memory>");
struct JPGLoadingContext;
diff --git a/Userland/Libraries/LibGfx/PBMLoader.cpp b/Userland/Libraries/LibGfx/PBMLoader.cpp
index 573c174fc4..a90cd05c80 100644
--- a/Userland/Libraries/LibGfx/PBMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PBMLoader.cpp
@@ -102,12 +102,9 @@ RefPtr<Gfx::Bitmap> load_pbm(const StringView& path)
return load<PBMLoadingContext>(path);
}
-RefPtr<Gfx::Bitmap> load_pbm_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_pbm_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
- auto bitmap = load_impl<PBMLoadingContext>(data, length);
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PBM: <memory>", bitmap->size()));
- return bitmap;
+ return load_from_memory<PBMLoadingContext>(data, length, mmap_name);
}
PBMImageDecoderPlugin::PBMImageDecoderPlugin(const u8* data, size_t size)
diff --git a/Userland/Libraries/LibGfx/PBMLoader.h b/Userland/Libraries/LibGfx/PBMLoader.h
index 06fd5ecb75..1c022f9e45 100644
--- a/Userland/Libraries/LibGfx/PBMLoader.h
+++ b/Userland/Libraries/LibGfx/PBMLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_pbm(const StringView& path);
-RefPtr<Gfx::Bitmap> load_pbm_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_pbm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PBMLoadingContext;
diff --git a/Userland/Libraries/LibGfx/PGMLoader.cpp b/Userland/Libraries/LibGfx/PGMLoader.cpp
index 79323d0981..be2aad4821 100644
--- a/Userland/Libraries/LibGfx/PGMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PGMLoader.cpp
@@ -104,12 +104,9 @@ RefPtr<Gfx::Bitmap> load_pgm(const StringView& path)
return load<PGMLoadingContext>(path);
}
-RefPtr<Gfx::Bitmap> load_pgm_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_pgm_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
- auto bitmap = load_impl<PGMLoadingContext>(data, length);
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PGM: <memory>", bitmap->size()));
- return bitmap;
+ return load_from_memory<PGMLoadingContext>(data, length, mmap_name);
}
PGMImageDecoderPlugin::PGMImageDecoderPlugin(const u8* data, size_t size)
diff --git a/Userland/Libraries/LibGfx/PGMLoader.h b/Userland/Libraries/LibGfx/PGMLoader.h
index bb2ab9c15b..dab535e3be 100644
--- a/Userland/Libraries/LibGfx/PGMLoader.h
+++ b/Userland/Libraries/LibGfx/PGMLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_pgm(const StringView& path);
-RefPtr<Gfx::Bitmap> load_pgm_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_pgm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PGMLoadingContext;
diff --git a/Userland/Libraries/LibGfx/PNGLoader.cpp b/Userland/Libraries/LibGfx/PNGLoader.cpp
index 2f3512a831..70f458a211 100644
--- a/Userland/Libraries/LibGfx/PNGLoader.cpp
+++ b/Userland/Libraries/LibGfx/PNGLoader.cpp
@@ -174,17 +174,14 @@ RefPtr<Gfx::Bitmap> load_png(String const& path)
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- auto bitmap = load_png_impl((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PNG: {}", bitmap->size(), LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_png_from_memory((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
-RefPtr<Gfx::Bitmap> load_png_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_png_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
auto bitmap = load_png_impl(data, length);
if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PNG: <memory>", bitmap->size()));
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PNG: {}", bitmap->size(), mmap_name));
return bitmap;
}
diff --git a/Userland/Libraries/LibGfx/PNGLoader.h b/Userland/Libraries/LibGfx/PNGLoader.h
index 49f5c17906..56b0860c3b 100644
--- a/Userland/Libraries/LibGfx/PNGLoader.h
+++ b/Userland/Libraries/LibGfx/PNGLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_png(String const& path);
-RefPtr<Gfx::Bitmap> load_png_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_png_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PNGLoadingContext;
diff --git a/Userland/Libraries/LibGfx/PPMLoader.cpp b/Userland/Libraries/LibGfx/PPMLoader.cpp
index 41d9587941..0d8112a0ae 100644
--- a/Userland/Libraries/LibGfx/PPMLoader.cpp
+++ b/Userland/Libraries/LibGfx/PPMLoader.cpp
@@ -106,12 +106,9 @@ RefPtr<Gfx::Bitmap> load_ppm(const StringView& path)
return load<PPMLoadingContext>(path);
}
-RefPtr<Gfx::Bitmap> load_ppm_from_memory(const u8* data, size_t length)
+RefPtr<Gfx::Bitmap> load_ppm_from_memory(u8 const* data, size_t length, String const& mmap_name)
{
- auto bitmap = load_impl<PPMLoadingContext>(data, length);
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded PPM: <memory>", bitmap->size()));
- return bitmap;
+ return load_from_memory<PPMLoadingContext>(data, length, mmap_name);
}
PPMImageDecoderPlugin::PPMImageDecoderPlugin(const u8* data, size_t size)
diff --git a/Userland/Libraries/LibGfx/PPMLoader.h b/Userland/Libraries/LibGfx/PPMLoader.h
index 0e20adf3ab..5668cfc8f1 100644
--- a/Userland/Libraries/LibGfx/PPMLoader.h
+++ b/Userland/Libraries/LibGfx/PPMLoader.h
@@ -6,13 +6,14 @@
#pragma once
+#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
namespace Gfx {
RefPtr<Gfx::Bitmap> load_ppm(const StringView& path);
-RefPtr<Gfx::Bitmap> load_ppm_from_memory(const u8*, size_t);
+RefPtr<Gfx::Bitmap> load_ppm_from_memory(u8 const*, size_t, String const& mmap_name = "<memory>");
struct PPMLoadingContext;
diff --git a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h
index 0130f07654..569694fbc3 100644
--- a/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h
+++ b/Userland/Libraries/LibGfx/PortableImageLoaderCommon.h
@@ -261,19 +261,23 @@ static RefPtr<Gfx::Bitmap> load_impl(const u8* data, size_t data_size)
}
return context.bitmap;
}
+
+template<typename TContext>
+static RefPtr<Gfx::Bitmap> load_from_memory(u8 const* data, size_t length, String const& mmap_name)
+{
+ auto bitmap = load_impl<TContext>(data, length);
+ if (bitmap)
+ bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded {}: {}", bitmap->size(), TContext::image_type, mmap_name));
+ return bitmap;
+}
+
template<typename TContext>
static RefPtr<Gfx::Bitmap> load(const StringView& path)
{
auto file_or_error = MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;
- auto bitmap = load_impl<TContext>((const u8*)file_or_error.value()->data(), file_or_error.value()->size());
- if (bitmap)
- bitmap->set_mmap_name(String::formatted("Gfx::Bitmap [{}] - Decoded {}: {}",
- bitmap->size(),
- TContext::image_type,
- LexicalPath::canonicalized_path(path)));
- return bitmap;
+ return load_from_memory<TContext>((u8 const*)file_or_error.value()->data(), file_or_error.value()->size(), LexicalPath::canonicalized_path(path));
}
}