#pragma once #include #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; }; // 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); // 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); // encodes an av::frame with yuv pixelformat (is used by save_as_jpg()). void encode_as_jpg(av::frame const & frame, std::string const & filename);