2021-01-22 11:46:09 +01:00
|
|
|
/*
|
2024-06-18 21:06:15 +02:00
|
|
|
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
2021-01-22 11:46:09 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-22 11:46:09 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-06-18 21:06:15 +02:00
|
|
|
#include <AK/Forward.h>
|
2023-03-15 11:08:43 +01:00
|
|
|
#include <AK/Optional.h>
|
2024-06-18 21:06:15 +02:00
|
|
|
#include <AK/Span.h>
|
2021-04-19 23:43:04 +02:00
|
|
|
#include <LibGfx/Forward.h>
|
2021-01-22 11:46:09 +01:00
|
|
|
|
|
|
|
|
namespace Gfx {
|
|
|
|
|
|
2023-03-15 11:08:43 +01:00
|
|
|
// This is not a nested struct to work around https://llvm.org/PR36684
|
|
|
|
|
struct PNGWriterOptions {
|
|
|
|
|
// Data for the iCCP chunk.
|
|
|
|
|
// FIXME: Allow writing cICP, sRGB, or gAMA instead too.
|
|
|
|
|
Optional<ReadonlyBytes> icc_data;
|
|
|
|
|
};
|
|
|
|
|
|
2021-01-22 11:46:09 +01:00
|
|
|
class PNGWriter {
|
|
|
|
|
public:
|
2023-03-15 11:08:43 +01:00
|
|
|
using Options = PNGWriterOptions;
|
|
|
|
|
|
|
|
|
|
static ErrorOr<ByteBuffer> encode(Gfx::Bitmap const&, Options options = Options {});
|
2021-01-22 11:46:09 +01:00
|
|
|
|
|
|
|
|
private:
|
2022-03-14 13:26:37 -06:00
|
|
|
PNGWriter() = default;
|
2021-01-22 11:46:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|