diff options
author | Nico Weber <thakis@chromium.org> | 2020-11-25 09:51:31 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-26 09:59:46 +0100 |
commit | ec4c2f971bacc22b4c781a08fb5d87b913aab154 (patch) | |
tree | 0ca8f8cf702927778802198930071a7e445beeb5 /Libraries/LibGfx | |
parent | 4f12efe1917fbec7b3a2542e10c74ef5e3a21c9a (diff) | |
download | serenity-ec4c2f971bacc22b4c781a08fb5d87b913aab154.zip |
Lagom: Make BMP fuzzer look like the other image loader fuzzers
Diffstat (limited to 'Libraries/LibGfx')
-rw-r--r-- | Libraries/LibGfx/BMPLoader.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibGfx/BMPLoader.h | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/Libraries/LibGfx/BMPLoader.cpp b/Libraries/LibGfx/BMPLoader.cpp index 0918335b3a..c746e694ea 100644 --- a/Libraries/LibGfx/BMPLoader.cpp +++ b/Libraries/LibGfx/BMPLoader.cpp @@ -186,6 +186,14 @@ RefPtr<Gfx::Bitmap> load_bmp(const StringView& path) return bitmap; } +RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8* data, size_t length) +{ + auto bitmap = load_bmp_impl(data, length); + if (bitmap) + bitmap->set_mmap_name(String::format("Gfx::Bitmap [%dx%d] - Decoded BMP: <memory>", bitmap->width(), bitmap->height())); + return bitmap; +} + static const LogStream& operator<<(const LogStream& out, Endpoint<i32> ep) { return out << "(" << ep.x << ", " << ep.y << ", " << ep.z << ")"; diff --git a/Libraries/LibGfx/BMPLoader.h b/Libraries/LibGfx/BMPLoader.h index 6493b196ea..92f54e6b5f 100644 --- a/Libraries/LibGfx/BMPLoader.h +++ b/Libraries/LibGfx/BMPLoader.h @@ -26,13 +26,13 @@ #pragma once -#include <AK/Vector.h> #include <LibGfx/Bitmap.h> #include <LibGfx/ImageDecoder.h> namespace Gfx { RefPtr<Gfx::Bitmap> load_bmp(const StringView& path); +RefPtr<Gfx::Bitmap> load_bmp_from_memory(const u8*, size_t); struct BMPLoadingContext; |