forked from Bananymous/banan-os
image: Remove inheritance from Netbpm
This inheritance made no sense
This commit is contained in:
parent
fdb6dc94ba
commit
8564b59e14
|
@ -70,7 +70,7 @@ BAN::UniqPtr<Image> Image::load_from_file(BAN::StringView path)
|
||||||
case 0x3350:
|
case 0x3350:
|
||||||
case 0x3250:
|
case 0x3250:
|
||||||
case 0x3150:
|
case 0x3150:
|
||||||
if (auto res = Netbpm::create(addr, st.st_size); res.is_error())
|
if (auto res = load_netbpm(addr, st.st_size); res.is_error())
|
||||||
fprintf(stderr, "%s\n", strerror(res.error().get_error_code()));
|
fprintf(stderr, "%s\n", strerror(res.error().get_error_code()));
|
||||||
else
|
else
|
||||||
image = res.release_value();
|
image = res.release_value();
|
||||||
|
|
|
@ -22,15 +22,17 @@ public:
|
||||||
|
|
||||||
bool render_to_framebuffer();
|
bool render_to_framebuffer();
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
Image(uint64_t width, uint64_t height, BAN::Vector<Color>&& bitmap)
|
Image(uint64_t width, uint64_t height, BAN::Vector<Color>&& bitmap)
|
||||||
: m_width(width)
|
: m_width(width)
|
||||||
, m_height(height)
|
, m_height(height)
|
||||||
, m_bitmap(BAN::move(bitmap))
|
, m_bitmap(BAN::move(bitmap))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
const uint64_t m_width;
|
const uint64_t m_width;
|
||||||
const uint64_t m_height;
|
const uint64_t m_height;
|
||||||
const BAN::Vector<Color> m_bitmap;
|
const BAN::Vector<Color> m_bitmap;
|
||||||
|
|
||||||
|
friend class BAN::UniqPtr<Image>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@ BAN::Optional<uint64_t> parse_u64(const uint8_t*& data, size_t data_size)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<BAN::UniqPtr<Netbpm>> Netbpm::create(const void* mmap_addr, size_t size)
|
BAN::ErrorOr<BAN::UniqPtr<Image>> load_netbpm(const void* mmap_addr, size_t size)
|
||||||
{
|
{
|
||||||
if (size < 11)
|
if (size < 11)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ BAN::ErrorOr<BAN::UniqPtr<Netbpm>> Netbpm::create(const void* mmap_addr, size_t
|
||||||
|
|
||||||
printf("Netbpm image %llux%llu\n", *width, *height);
|
printf("Netbpm image %llux%llu\n", *width, *height);
|
||||||
|
|
||||||
BAN::Vector<Color> bitmap;
|
BAN::Vector<Image::Color> bitmap;
|
||||||
TRY(bitmap.resize(*width * *height));
|
TRY(bitmap.resize(*width * *height));
|
||||||
|
|
||||||
// Fill bitmap
|
// Fill bitmap
|
||||||
|
@ -104,5 +104,5 @@ BAN::ErrorOr<BAN::UniqPtr<Netbpm>> Netbpm::create(const void* mmap_addr, size_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRY(BAN::UniqPtr<Netbpm>::create(*width, *height, BAN::move(bitmap)));
|
return TRY(BAN::UniqPtr<Image>::create(*width, *height, BAN::move(bitmap)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,3 @@
|
||||||
#include "Image.h"
|
#include "Image.h"
|
||||||
|
|
||||||
class Netbpm : public Image
|
BAN::ErrorOr<BAN::UniqPtr<Image>> load_netbpm(const void* mmap_addr, size_t size);
|
||||||
{
|
|
||||||
public:
|
|
||||||
static BAN::ErrorOr<BAN::UniqPtr<Netbpm>> create(const void* mmap_addr, size_t size);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Netbpm(uint64_t width, uint64_t height, BAN::Vector<Color>&& bitmap)
|
|
||||||
: Image(width, height, BAN::move(bitmap))
|
|
||||||
{ }
|
|
||||||
|
|
||||||
friend class BAN::UniqPtr<Netbpm>;
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue