/* * Copyright (c) 2022, Olivier De Cannière * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Gfx { enum class Colorspace; enum class Channels; class QOIWriter { public: static ErrorOr encode(Gfx::Bitmap const&); private: QOIWriter() = default; Vector m_data; ErrorOr add_header(u32 width, u32 height, Channels, Colorspace); ErrorOr add_rgb_chunk(u8, u8, u8); ErrorOr add_rgba_chunk(u8, u8, u8, u8); ErrorOr add_index_chunk(u32 index); ErrorOr add_diff_chunk(i8 red_difference, i8 green_difference, i8 blue_difference); ErrorOr add_luma_chunk(i8 relative_red_difference, i8 green_difference, i8 relative_blue_difference); ErrorOr add_run_chunk(u32 run_length); ErrorOr add_end_marker(); Array running_array; static u32 pixel_hash_function(Color pixel); void insert_into_running_array(Color pixel); }; }