#pragma once

#include "foundation/result.h"

#include <cstddef>
#include <cstdint>
#include <span>
#include <vector>

namespace pp::assets {

struct Rgba8Image {
    std::uint32_t width = 0;
    std::uint32_t height = 0;
    std::vector<std::uint8_t> pixels;
};

[[nodiscard]] pp::foundation::Result<Rgba8Image> decode_png_rgba8(
    std::span<const std::byte> bytes);

[[nodiscard]] pp::foundation::Result<Rgba8Image> decode_jpeg_rgba8(
    std::span<const std::byte> bytes);

[[nodiscard]] pp::foundation::Result<std::vector<std::byte>> encode_png_rgba8(
    std::uint32_t width,
    std::uint32_t height,
    std::span<const std::uint8_t> pixels);

[[nodiscard]] pp::foundation::Result<std::vector<std::byte>> encode_jpeg_rgba8(
    std::uint32_t width,
    std::uint32_t height,
    std::span<const std::uint8_t> pixels,
    int quality);

[[nodiscard]] pp::foundation::Result<std::vector<std::byte>> inject_gpano_xmp_into_jpeg(
    std::span<const std::byte> jpeg);

}
