Bitmap/Read a PPM file: Difference between revisions
Content added Content deleted
(→{{header|Euphoria}}: Euphoria example added) |
(Add Seed7 example) |
||
Line 1,213: | Line 1,213: | ||
} |
} |
||
}</lang> |
}</lang> |
||
=={{header|Seed7}}== |
|||
<lang seed7>$ include "seed7_05.s7i"; |
|||
include "draw.s7i"; |
|||
include "color.s7i"; |
|||
const func PRIMITIVE_WINDOW: getPPM (in string: fileName) is func |
|||
result |
|||
var PRIMITIVE_WINDOW: aWindow is PRIMITIVE_WINDOW.value; |
|||
local |
|||
var file: ppmFile is STD_NULL; |
|||
var string: line is ""; |
|||
var integer: width is 0; |
|||
var integer: height is 0; |
|||
var integer: x is 0; |
|||
var integer: y is 0; |
|||
var color: pixColor is black; |
|||
begin |
|||
ppmFile := open(fileName, "r"); |
|||
if ppmFile <> STD_NULL then |
|||
if getln(ppmFile) = "P6" then |
|||
repeat |
|||
line := getln(ppmFile); |
|||
until line = "" or line[1] <> '#'; |
|||
read(ppmFile, width); |
|||
readln(ppmFile, height); |
|||
aWindow := newPixmap(width, height); |
|||
for y range 0 to pred(height) do |
|||
for x range 0 to pred(width) do |
|||
pixColor.red_part := ord(getc(ppmFile)); |
|||
pixColor.green_part := ord(getc(ppmFile)); |
|||
pixColor.blue_part := ord(getc(ppmFile)); |
|||
end for; |
|||
end for; |
|||
end if; |
|||
close(ppmFile); |
|||
end if; |
|||
end func;</lang> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |