Home|Projects|About

Console Image Renderer/Image Distorter, C++, 7.13.2022

I think everyone has made at least one of these in their time programming. It isn't exactly a hard thing to do, you just load an image into memory, somehow compress it to your desired size, then sample the pixels using a lookup table for different darkness/lightness values.


This took me like, a couple minutes to make. Seriously, anyone can make one of these, it would actually probably be a pretty good project for beginners, to get used to using external libraries- or maybe even understand loading in bitmap files or something.


I was originally going to make something considerably more advanced, using edge detection to approximate with line characters like \/|_, gave up after making the edge detection algorithm though. I can't remember what made me switch gears, but I decided to take this as an excuse to finally tackle ANSI escape codes.
I had never been able to get them to work in the past, ends up its an issue with the windows terminal not having them on by default. You have to jump through some very stupid hoops with the windows api to enable it. Fun fact: in python you can just include system and call system('') and it'll enable them. Wish I'da known while making Rogue Adjacent

Next I made two changes, one: started using background and foreground with the half width character to get square pixels, two: started using the 24 bit colour mode. This was also brutally easy, but the project suddenly switched gears

At some point in switching over to 24 bit colour, I fell for one of the classic blunders: accidentally reversed a number in the process of converting it from an int to a string. That string was the colour data. The test image, which was a (very edgy) drawing I had been working on got completely distorted.
Honestly, I lucked out with this one, it looks dope. It essentally had the effect of swapping the low and high frequency noise, and also lost some detail (due to decimal to binary conversion and byte size)

Pretty quickly I decided that this was too cool for the terminal, and made a program that took an input png and created an output png.



Not much else to say about this, that last one and the first one are my favourites. This is one thing that I think might actually be worth downloading, if you like the aesthetic. Check it out here.