Note---- I use BORLAND TURBO C++
I know that Turbo C++ is two decades old, and it does not support the latest C++ standard either. But since our school still uses it to teach students C++, I can't use any other compiler.
I want to display an image in Turbo C++ using ASCII text. I have already converted the image to ASCII code using an online converter. What should I do now to display it in my program?
I was thinking of something along these lines-
- Copy the ASCII code to a txt file.
- Read the text file using the getline function.
- Display it on the output screen.
I thought it would work, but the difficulty arises when I copy the ASCII image to notepad. It destroys all the formatting of the ASCII image, and the image just becomes a rectangular block of text.
Is there any other way to achieve this? I do not want to use any other libraries if I can help it. I use the graphics.h library in Turbo C++. Also, I am a bit new to C++ (started learning it last year), so I would be grateful if you keep the answers as simple as possible.
Well, the first option is to find another online converter which gives you a raw, copy-able, output. In that case you can use your approach.
The second way is to build an ascii converter yourself. The way I think the online tools convert an image into ascii characters is the following:
Build a table with relative brightness, so: space is 0 brightness, 8 = 60% brightness 0 is 80% birghtness # is 90% brightness and go on like this.
this is more complicated, and if you are new you could probably try your approach first.