Anonymous user
Bitmap/Read a PPM file: Difference between revisions
→{{header|AutoHotkey}}: fixed error in pixel making loop
(→{{header|AutoHotkey}}: fixed error in pixel making loop) |
|||
Line 89:
end;</lang>
=={{header|AutoHotkey}}==
{{works with | AutoHotkey_L}}
<lang AutoHotkey>img := ppm_read("blue.ppm")▼
Only ppm3 ascii files supported.
x := img[4,4] ; get pixel(4,4)
msgbox % "img: 4,4,R,G,B, RGB: " x.R ", " x.G ", " x.B ", " x.rgb()
img.write("
return
ppm_read(filename, ppmo=0) ; only ppm3 files supported (ascii)
{
if !ppmo ; if image not already in memory, read from filename
fileread, ppmo, % filename, utf-8
loop, parse, ppmo, `n, `r
Line 113 ⟶ 117:
Break
index ++
}
type := bitmap1
width := bitmap2
Line 121 ⟶ 125:
maxcolor := bitmap4
bitmap := Bitmap(width, height, color(0,0,0))
index := 1
width := 1
height := 1
while pos := regexmatch(ppm_nocomment, "\d+", pixel, pos)
{
pix%
index++
if (index > 3)
Line 143 ⟶ 147:
width++
}
pos := regexmatch(ppm_nocomment, "\s", x, pos)
return bitmap
}
#include bitmap_storage.ahk ; from http://rosettacode.org/wiki/Basic_bitmap_storage/AutoHotkey
</lang>
|