Bitmap/Write a PPM file: Difference between revisions

Content added Content deleted
(Added 11l)
Line 50: Line 50:
F writeppmp3()
F writeppmp3()
V magic = "P3\n"
V magic = "P3\n"
V comment = "# generated from Bitmap.writeppm3\n"
V comment = "# generated from Bitmap.writeppmp3\n"
V s = magic‘’comment‘’("#. #.\n#.\n".format(.width, .height, 255))
V s = magic‘’comment‘’("#. #.\n#.\n".format(.width, .height, 255))
L(h) (.height - 1 .< -1).step(-1)
L(h) (.height - 1 .< -1).step(-1)
Line 59: Line 59:
R s
R s


F writeppm6()
F writeppmp6()
V magic = "P6\n"
V magic = "P6\n"
V comment = "# generated from Bitmap.writeppm6\n"
V comment = "# generated from Bitmap.writeppmp6\n"
[Byte] b
[Byte] b
b [+]= magic.encode()
b [+]= magic.encode()
Line 77: Line 77:
print(bitmap.writeppmp3())
print(bitmap.writeppmp3())


File(‘tmp.ppm’, ‘w’).write_bytes(bitmap.writeppm6())</lang>
File(‘tmp.ppm’, ‘w’).write_bytes(bitmap.writeppmp6())</lang>


{{out}}
{{out}}
<pre>
<pre>
P3
P3
# generated from Bitmap.writeppm3
# generated from Bitmap.writeppmp3
4 4
4 4
255
255