Using the data storage type defined on this page for raster images, write the image to a PPM file (binary P6 prefered).

(Read the definition of PPM file on Wikipedia.)




 100 W = 8
 110 H = 8
 120 BA = 24576
 130  HIMEM: 8192
 140 D$ =  CHR$ (4)
 150 M$ =  CHR$ (13)
 160 P6$ = "P6" + M$ +  STR$ (W) + " " +  STR$ (H) + M$ + "255" + M$
 170  FOR I = 1 TO  LEN (P6$)
 180      POKE BA + I - 1, ASC ( MID$ (P6$,I,1))
 190  NEXT I
 200 BB = BA + I - 1
 210 BL = (BB + W * H * 3) - BA
 220 C = 255 + 255 * 256 + 0 * 65536: GOSUB 600FILL
 230 X = 4:Y = 5:C = 127 + 127 * 256 + 255 * 65536: GOSUB 500"SET PIXEL"
 240  PRINT D$"BSAVE BITMAP.PPM,A"BA",L"BL
 250  END 
 500 R = C -  INT (C / 256) * 256:B =  INT (C / 65536):G =  INT (C / 256) - B * 256:A = BB + X * 3 + Y * W * 3: POKE A,R: POKE A + 1,G: POKE A + 2,B: RETURN 
 600  FOR Y = 0 TO H - 1: FOR X = 0 TO W - 1: GOSUB 500: NEXT X,Y: RETURN