#pragma once #include "av.hpp" #include #include #include #include // Basic image representation // 3 bytes per pixel (rgb), so size of data is width*height*3 struct raw_rgb_image { std::vector> data; av::frame frame; raw_rgb_image(); raw_rgb_image(int W, int H); int width() const; int height() const; AVPixelFormat format() const; }; // dumps image in ppm format void save_as_ppm(raw_rgb_image const & image, std::string const & filename); // opens an image in its own format av::frame open_image(std::string const & filename); // crops to the bottom right square (cheap operation) void crop_to_square(av::frame & frame); av::frame crop_to_square(av::frame const & frame); av::frame crop_to_square(av::frame && frame); // converts and resizes raw_rgb_image to_raw_rgb_image(av::frame const & frame, int new_width, int new_height); // Legacy inline raw_rgb_image open_as_rgb(const std::string &filename){ return to_raw_rgb_image(crop_to_square(open_image(filename)), 512, 512); } // apply function to every tile, fun :: Column, Row, Image -> Void void apply_to_tiles(std::string const & filename, int h_tiles, int v_tiles, std::function fun); // does what you think it does void save_as_jpg(av::frame const & frame, std::string const & filename);