Bitmap/Read a PPM file: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Fixed a potential timing issue with FileSystem.load.) |
(Added FreeBASIC) |
||
Line 1,670: | Line 1,670: | ||
* doing formatted I/O with Fortran is a pain... And unformatted does not mean ''free''; Fortran2003 has ''streams'', but they are not implemented (yet) in GNU Fortran compiler. Here (as in the write part) I've tried to handle the PPM format through formatted I/O. The tests worked but I have not tried still everything. |
* doing formatted I/O with Fortran is a pain... And unformatted does not mean ''free''; Fortran2003 has ''streams'', but they are not implemented (yet) in GNU Fortran compiler. Here (as in the write part) I've tried to handle the PPM format through formatted I/O. The tests worked but I have not tried still everything. |
||
* comments after the first line are not handled |
* comments after the first line are not handled |
||
=={{header|FreeBASIC}}== |
|||
{{trans|Yabasic}} |
|||
<syntaxhighlight lang="vbnet">Dim As String imagen = "Lena.ppm" |
|||
Sub readPPM (fs As String) |
|||
Dim As Integer x, y, ancho, alto |
|||
Dim As String t, kolor |
|||
Dim As Ubyte r, g, b |
|||
If Len(fs) = 0 Then Print "No PPM file name indicated.": Exit Sub |
|||
Dim As Long ff = Freefile |
|||
Open fs For Binary As #ff |
|||
If Err Then Print "File "; fs; " not found.": Exit Sub |
|||
Input #ff, t, ancho, alto, kolor |
|||
If t = "P6" Then |
|||
Screenres ancho, alto, 32 |
|||
For y = 0 To alto - 1 |
|||
For x = 0 To ancho - 1 |
|||
Get #ff, , r |
|||
Get #ff, , g |
|||
Get #ff, , b |
|||
Pset (x, y), Rgb(r, g, b) |
|||
Next x |
|||
Next y |
|||
Close #ff |
|||
Else |
|||
Print "File is NOT PPM P6 type." |
|||
End If |
|||
End Sub |
|||
readPPM(imagen) |
|||
Sleep</syntaxhighlight> |
|||
=={{header|Go}}== |
=={{header|Go}}== |
||
<syntaxhighlight lang="go">package raster |
<syntaxhighlight lang="go">package raster |