#pragma once

#include "foundation/result.h"

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

namespace pp::assets {

constexpr std::uint32_t max_image_dimension = 262144;

enum class ImageColorType : std::uint8_t {
    grayscale,
    rgb,
    indexed,
    grayscale_alpha,
    rgba,
};

struct ImageMetadata {
    std::uint32_t width = 0;
    std::uint32_t height = 0;
    std::uint8_t bit_depth = 0;
    std::uint8_t components = 0;
    ImageColorType color_type = ImageColorType::rgba;
};

[[nodiscard]] pp::foundation::Result<ImageMetadata> parse_png_metadata(
    std::span<const std::byte> bytes) noexcept;

[[nodiscard]] const char* image_color_type_name(ImageColorType color_type) noexcept;

}
