NXT / pbLua dump screen to XPM
With very little effort one can change the function DumpDisplay from the tutorial to a DumpDisplayToXPM, which will create a human-readable as well as computer readable file.
/* XPM */
static char *xpm_[] = {
"100 64 2 1",
"* c #000000",
". c #ffffff",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"....................................................................................................",
"......*.....*.......................****.........*..................*...*****.*.....................",
"......*.....*.......................*...*........*.................**...*.....*.....................",
"****..*.**..*.....*...*..***........*...*..***..***....***..........*...****..*.**..................",
"*...*.**..*.*.....*...*.....*.......****..*...*..*........*.........*.......*.**..*.................",
"****..*...*.*.....*...*..****.......*...*.*****..*.....****.........*.......*.*...*.................",
"*.....*...*.*.....*..**.*...*.......*...*.*......*..*.*...*.........*...*...*.*...*.................",
"*.....****..*****..**.*..****.......****...***....**...****........***...***..****..................",
"....................................................................................................",
};
Using PixelMator this can easily be translated to PNG:

Here’s the function:
function DumpDisplayToXPM()
print("/* XPM */")
print("static char *xpm_[] = {")
print("\"100 64 2 1\",")
print("\"* c #000000\",")
print("\". c #ffffff\",")
for y=0,63 do
s = ""
for x=0,99 do
if 0 ~= nxt.DisplayGetPixel(x,y) then
s = s .. "*"
else
s = s .. "."
end
end
print( "\"" .. s .. "\"," )
end
print("};")
end
Currently this function outputs to the console, which is fine for our purpose, so we can copy and paste it over to our computer.
As said earlier, I’m using MacVim which supports XPM natively.


