/* * Copyright (c) 2023, Lucas Chollet * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Gfx { // This is not a nested struct to work around https://llvm.org/PR36684 struct PortableFormatWriterOptions { enum class Format { ASCII, Raw, }; Format format = Format::Raw; StringView comment = "Generated with SerenityOS - LibGfx."sv; }; class PortableFormatWriter { public: using Options = PortableFormatWriterOptions; static ErrorOr encode(Bitmap const&, Options options = Options {}); private: PortableFormatWriter() = delete; static ErrorOr add_header(ByteBuffer&, Options const& options, u32 width, u32 height, u32 max_value); static ErrorOr add_pixels(ByteBuffer&, Options const& options, Bitmap const&); }; }