Bitmap/Write a PPM file: Difference between revisions

→‎Ada: Fixed tipo an better reference
(→‎{{header|Wren}}: Updated, about 90 times faster than before.)
(→‎Ada: Fixed tipo an better reference)
Tags: Mobile edit Mobile web edit
(2 intermediate revisions by 2 users not shown)
Line 76:
print(bitmap.writeppmp3())
 
File(‘tmp.ppm’, ‘w’WRITE).write_bytes(bitmap.writeppmp6())</syntaxhighlight>
 
{{out}}
Line 89:
0 0 0 255 255 255 0 0 0 0 0 0
</pre>
 
=={{header|Action!}}==
{{libheader|Action! Bitmap tools}}
Line 203 ⟶ 204:
<syntaxhighlight lang="ada">with Ada.Characters.Latin_1;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
 
with Bitmap_Store; use Bitmap_Store;
-- This package is defined in the Bitmap task.
 
procedure Put_PPM (File : File_Type; Picture : Image) is
Line 228 ⟶ 232:
end Put_PPM;</syntaxhighlight>
The solution writes the image into an opened file. The file format might fail to work on certain [[OS]]es, because output might mangle control characters like LF, CR, FF, HT, VT etc. The OS might also limit the line length of a text file. In general it is a bad idea to mix binary and text output in one file. This solution uses ''stream I/O'', which should be as portable as possible.
 
=={{header|Aime}}==
<syntaxhighlight lang="aime">integer i, h, j, w;
14

edits