#pragma once
#include <cstdint>
#include <string>
#include <vector>
#include "font.h"
#include "rect.h"
#include "vec2.h"

using color = uint32_t;

struct image {
	image(vec2i size);
	image(vec2i size, color* data);
	image(std::string path);
	image(image const& other);
	~image();
	//static image_from_pointer()

	vec2i const& size() const;
	recti const& bounds() const;

	color* raw_pointer() const;
	color get(vec2i pos) const;

	void clear(color color);

	void draw(image const& image, vec2i pos);
	void draw(image const& image, vec2i pos, recti src_rect);
	void draw(image const& image, vec2i pos, color color);
	void draw(image const& image, vec2i pos, color color, recti src_rect);
	void draw_upscaled(image const& image);

	void draw(std::string const& str, vec2i pos, font const& font, color color);
	void draw(std::string const& str, vec2i pos, font const& font, color color1, color color2);
private:
	bool _borrowed_pointer; //to know if to free or not
	color* _data; //not a vector so can wrap sdl surfaces
	recti _bounds;
};
