-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpnm.fs
62 lines (54 loc) · 1.27 KB
/
pnm.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
\ Parse Portable Anymap (PNM) from input stream and write to buffer
\ Supported Variants: P3 with 24bit colors is supported ( gimp used )
\ (c) copyright 2015 by Gerald Wodni <[email protected]>
: not-supported ( -- )
." Format not supported" ;
\ read next line, ignore comments
: pnm-query
begin
query cr source drop c@ [char] # <>
until ;
\ parse pnm-header
: pnm-header ( -- x y )
pnm-query interpret \ read x & y
query interpret drop \ read maximum value ( and ignore it ! )
;
\ currently only P3 is supported
: P1 not-supported ;
: P2 not-supported ;
: P4 not-supported ;
: P5 not-supported ;
: P6 not-supported ;
\ parse Portable Pixmap (ASCII)
: P3 pnm-header
buffer-off
0 do \ rows
dup 0 do \ columns
query interpret 16 lshift \ red
query interpret 8 lshift \ green
query interpret \ blue
or or \ combine
i j xy! \ store
loop
loop drop z-flush ; \ flush to leds
\ dummy word: read type and
: pnm-here
\ read header
query interpret
;
\ 3 pixels (RGB)
\ TODO: will not work with e4thcom.fs
\ pnm-here
\ P3
\ # hallo
\ 3 1
\ 255
\ 255
\ 0
\ 0
\ 1
\ 255
\ 1
\ 2
\ 2
\ 255