Bitmap/Read a PPM file: Difference between revisions

Content added Content deleted
(→‎{{header|AutoHotkey}}: read ppm6 instead of ppm3)
(Added PicoLisp)
Line 758: Line 758:
end is_digit;
end is_digit;
end test;</lang>
end test;</lang>

=={{header|PicoLisp}}==
<lang PicoLisp>(de ppmRead (File)
(in File
(unless (and `(hex "5036") (rd 2)) # P6
(quit "Wrong file format" File) )
(rd 1)
(let (DX 0 DY 0 Max 0 C)
(while (>= 9 (setq C (- (rd 1) `(char "0"))) 0)
(setq DX (+ (* 10 DX) C)) )
(while (>= 9 (setq C (- (rd 1) `(char "0"))) 0)
(setq DY (+ (* 10 DY) C)) )
(while (>= 9 (setq C (- (rd 1) `(char "0"))) 0)
(setq Max (+ (* 10 Max) C)) )
(prog1
(make (do DY (link (need DX))))
(for Y @
(map
'((X) (set X (list (rd 1) (rd 1) (rd 1))))
Y ) ) ) ) ) )</lang>
Read a color image "img.ppm", convert and write to "img.pgm":
<lang PicoLisp>(pgmWrite (ppm->pgm (ppmRead "img.ppm")) "img.pgm")</lang>


=={{header|PureBasic}}==
=={{header|PureBasic}}==