LibImage: Implement (bi)cubic interpolation

This is kind of slow but yields much nicer results compared to
(bi)linear interpolation. I should probably add gamma correction...
This commit is contained in:
2024-06-15 23:05:10 +03:00
parent 157e05f57c
commit e6549b0fe8
2 changed files with 99 additions and 24 deletions

View File

@@ -36,13 +36,14 @@ namespace LibImage
enum class ResizeAlgorithm
{
Nearest,
Bilinear,
Linear,
Cubic,
};
public:
static BAN::ErrorOr<BAN::UniqPtr<Image>> load_from_file(BAN::StringView path);
BAN::ErrorOr<BAN::UniqPtr<Image>> resize(uint64_t new_width, uint64_t new_height, ResizeAlgorithm = ResizeAlgorithm::Bilinear);
BAN::ErrorOr<BAN::UniqPtr<Image>> resize(uint64_t new_width, uint64_t new_height, ResizeAlgorithm = ResizeAlgorithm::Cubic);
Color get_color(uint64_t x, uint64_t y) const { return m_bitmap[y * width() + x]; }
const BAN::Vector<Color> bitmap() const { return m_bitmap; }