From be144e2a05de77900a39923d7fc6dcc9a22e5bc8 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 18 Nov 2024 14:45:06 -0500 Subject: [PATCH] Start of image to ansi converter. --- meson.build | 9 +++++++++ scratchpad/img2ansi.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 scratchpad/img2ansi.cpp diff --git a/meson.build b/meson.build index 43c835e..550684f 100644 --- a/meson.build +++ b/meson.build @@ -53,4 +53,13 @@ roguish = executable('roguish', [ ], dependencies: dependencies) +roguish = executable('img2ansi', [ + 'dbc.cpp', + 'panel.cpp', + 'ansi_parser.cpp', + 'render.cpp', + 'scratchpad/img2ansi.cpp' + ], + dependencies: dependencies) + test('tests', runtests) diff --git a/scratchpad/img2ansi.cpp b/scratchpad/img2ansi.cpp new file mode 100644 index 0000000..21d991a --- /dev/null +++ b/scratchpad/img2ansi.cpp @@ -0,0 +1,31 @@ +#include +#include +#include "panel.hpp" +#include "color.hpp" +#include "render.hpp" +#include "dbc.hpp" +#include + +using namespace fmt; +using namespace std; + +int main(int argc, char *argv[]) { + dbc::check(argc == 2, "USAGE: img2ansi "); + + string image_file(argv[1]); + + println("LOADING IMAGE: {}", image_file); + + // load the image from argv + sf::Image image; + image.loadFromFile(image_file); + + // create a grid panel to hold the cells + // divide the image into cells + // for each cell: + // get the color + // calculate value + // find character that's closest + // write to panel/canvas with ftxui + // display in sfml window with renderer +}