RosettaCodeData/Task/Bitmap-Write-a-PPM-file/BQN/bitmap-write-a-ppm-file-1.bqn

16 lines
508 B
BQN

header_ppm "P6
4 8
255
"
red 25500 # a 3-element 1D list
grn 02550
ble 00255
blk 000
gry 128128128
wht 255255255
all redgrnbleblkgrywht # join "colors" to 1D list
image_ppm 843 all # reshape "all" to 8 rows by 4 cols by 3, "all" gets reused as needed to fill
image_ppm @ + image_ppm # deshape, convert to chars (uint8_t)
bytes_ppm header_ppm image_ppm
"small.ppm" •file.Bytes bytes_ppm