summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/BMPLoader.cpp
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/Libraries/LibGfx/BMPLoader.cpp
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/Libraries/LibGfx/BMPLoader.cpp')
-rw-r--r--Userland/Libraries/LibGfx/BMPLoader.cpp9
1 files changed, 3 insertions, 6 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;
}