Bitmap/Read a PPM file: Difference between revisions

Content added Content deleted
(C# implementation)
(+ AutoHotkey)
Line 91: Line 91:
Close (F2);
Close (F2);
end;
end;
</lang>
=={{header|AutoHotkey}}==
<lang AutoHotkey>
ppm =
(
P6
# lasdjkf
87 09
255
color data...
)
msgbox % ppm_width(ppm)
msgbox % ppm_height(ppm)
msgbox % ppm_colors(ppm)
msgbox % ppm_data(ppm)

ppm_read(file)
{
fileread, ppm, % file
return ppm
}

ppm_width(ppm)
{
regexmatch(ppm, "\R(\d+)\s(\d+)", dim)
return dim1
}
ppm_height(ppm)
{
regexmatch(ppm, "\R(\d+)\s(\d+)", dim)
return dim2
}

ppm_colors(ppm)
{
regexmatch(ppm, "\R(\d+)\D*\R", colors) ; \R stands for any
return colors1
}

ppm_data(ppm)
{
pos := regexmatch(ppm, "\R(\d+)\D*\R", colors) ; \R stands for any newline
stringtrimleft, data, ppm, pos + strlen(colors1)
return data
}
</lang>
</lang>