Bitmap/Read a PPM file: Difference between revisions
Content deleted Content added
Line 703: | Line 703: | ||
declare 1 pixel union, |
declare 1 pixel union, |
||
2 color bit(24) aligned, |
2 color bit(24) aligned, |
||
2 primary_colors, |
|||
3 R char (1), |
3 R char (1), |
||
3 G char (1), |
3 G char (1), |
||
Line 710: | Line 711: | ||
open file (in) title ('/IMAGE.PPM,TYPE(FIXED),RECSIZE(1)' ) input; |
open file (in) title ('/IMAGE.PPM,TYPE(FIXED),RECSIZE(1)' ) input; |
||
call get_char |
call get_char; |
||
ID = ch; |
ID = ch; |
||
call get_char |
call get_char; |
||
substr(ID, 2,1) = ch; |
substr(ID, 2,1) = ch; |
||
/* Read in the dimensions of the image */ |
/* Read in the dimensions of the image */ |
||
Line 736: | Line 737: | ||
end; |
end; |
||
get_char: procedure |
get_char: procedure; |
||
do until (ch ^= ' '); |
do until (ch ^= ' '); |
||
read file (in) into (ch) |
read file (in) into (ch); |
||
end; |
end; |
||
end get_char; |
end get_char; |
||
get_integer: procedure (value); |
get_integer: procedure (value); |
||
declare value fixed binary; |
declare value fixed binary (31); |
||
do until (ch = ' '); |
do until (ch = ' '); |
||
Line 751: | Line 752: | ||
do until (is_digit(ch)); |
do until (is_digit(ch)); |
||
value = value*10 + ch; |
value = value*10 + ch; |
||
read file ( |
read file (in) into (ch); |
||
end; |
end; |
||
end get_integer; |
end get_integer; |
||
is_digit: procedure (ch) returns (bit(1)); |
|||
⚫ | |||
declare ch character (1); |
|||
</lang> |
|||
return (index('0123456789', ch) > 0); |
|||
end is_digit; |
|||
⚫ | |||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |