I have an assignment on 8086 assembly (this is homework), I need to display a BMP image on screen and create an ASCII textfile from the BMP (like those ASCII art sofware do).
I have covered the display part, and I finished “translating” BMP to ASCII. However, as you know BMP files have the pixel row info upside down, that is, the topmost row is written last on the file.
So I thought that, for creating the .txt file, I could simply write a line, return the pointer to the start of the file, and then write another line, and so on. However, now it seems obvious to me that doing that would just overwrite the previous line, and I end up with a text file with just a single line.
So, in conclussion, my question is: Has anyone any suggestion as to how to approach this situation? I would very much appreciate any help. Thanks in advance!
PD: I’m not asking for direct solutions, there just may be something or some tool that I don’t know about, that can help me with this problem.
You cannot easily insert into a text file.
However, because you know how many rows of text to write, and what the length of each row is (including newline), you can seek to the correct part of the file and start writing there.
Begin by writing out entirely spaces (and newlines). Then for each scanline of text, seek to the appropriate location and output one line of text.
Alternatively, read the bitmap scanlines in reverse order.