Created
May 20, 2019 13:54
-
-
Save MikuroXina/1714d6c3cbe81b2a60e539f891c01e91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <boost/gil/typedefs.hpp> | |
#include <boost/gil/extension/io/png.hpp> | |
#include <boost/gil/extension/io/png/old.hpp> | |
int main(int argc, char** argv) | |
{ | |
namespace g = boost::gil; | |
if (argc <= 1) | |
return -1; | |
g::rgba8_image_t img; | |
g::png_read_and_convert_image(argv[1], img); | |
int scale = (img.width() + 79) / 80; | |
g::dynamic_xy_step_type<g::rgba8_image_t::view_t>::type img_v( | |
g::subsampled_view(g::view(img), scale, scale)); | |
for (g::rgba8_view_t::y_coord_t y = 0; y < img_v.height(); y += 2) { | |
for (g::rgba8_view_t::x_coord_t x = 0; x < img_v.width(); ++x) { | |
g::gray8_pixel_t gu, gl; | |
color_convert(img_v(x, y), gu); | |
if (y + 1 < img_v.height()) | |
color_convert(img_v(x, y + 1), gl); | |
std::cout << " .,`:;\"!|"[gl / 86 + (gu / 86) * 3]; | |
} | |
std::cout << std::endl; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment