pbm2scr: a graphic converter
I've published a graphic converter I wrote some months ago. It converts 256x192 PBM pictures to the ZX Spectrum SCR format.
It's written in Forth for Gforth.
For people acquainted with Forth, the interesting point is the header of all variants of the Netpbm format, ASCII and binary, is always ASCII and its elements (type identifier, picture width and height) are strings separated into lines. Therefore my approach was to interpret the picture file as a Forth source, using a word list that contains only the expected words, which do the parsing and conversion. As usual in Forth, you don't write a program, but extend the language to solve the problem.
The program is published on my website and on GitHub:
http://programandala.net/en.program.pbm2scr.html
It's written in Forth for Gforth.
For people acquainted with Forth, the interesting point is the header of all variants of the Netpbm format, ASCII and binary, is always ASCII and its elements (type identifier, picture width and height) are strings separated into lines. Therefore my approach was to interpret the picture file as a Forth source, using a word list that contains only the expected words, which do the parsing and conversion. As usual in Forth, you don't write a program, but extend the language to solve the problem.
The program is published on my website and on GitHub:
http://programandala.net/en.program.pbm2scr.html
Marcos Cruz (programandala.net)