#pragma once
#include <cstdint>
#include <memory>

#include "sokol_gfx.h"
#include "stb_image.h"

struct image_heap_t;

struct stb_image_info {
	int32_t width;
	int32_t height;
	int32_t channels;
	bool is_hdr;
	bool is_16_bit;

	[[nodiscard]] sg_pixel_format get_pixel_format() const;
};

class stb_image_loader {
public:
	void init(void* in_data, int32_t in_size);

	[[nodiscard]] stb_image_info get_info() const;
	[[nodiscard]] bool is_hdr() const;
	[[nodiscard]] bool is_16_bit() const;

	[[nodiscard]] float*                          load_hdr() const;
	[[nodiscard]] uint16_t*                       load_16_bit() const;
	[[nodiscard]] uint8_t*                        load_8_bit() const;
	[[nodiscard]] std::shared_ptr<image_heap_t> load() const;
private:
	stbi_uc* data_{};
	int32_t size_{};
};
