Module Checkit { Function Bitmap (x as long, y as long) { if x<1 or y<1 then Error "Wrong dimensions" structure rgb { red as byte green as byte blue as byte } m=len(rgb)*x mod 4 if m>0 then m=4-m ' add some bytes to raster line m+=len(rgb) *x Structure rasterline { { pad as byte*m } \\ union pad+hline hline as rgb*x } Structure Raster { magic as integer*4 w as integer*4 h as integer*4 lines as rasterline*y } Buffer Clear Image1 as Raster \\ 24 chars as header to be used from bitmap render build in functions Return Image1, 0!magic:="cDIB", 0!w:=Hex$(x,2), 0!h:=Hex$(y, 2) \\ fill white (all 255) \\ Str$(string) convert to ascii, so we get all characters from words width to byte width Return Image1, 0!lines:=Str$(String$(chrcode$(255), Len(rasterline)*y)) Buffer Clear Pad as Byte*4 SetPixel=Lambda Image1, Pad,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x, y, c) ->{ where=alines+3*x+blines*y if c>0 then c=color(c) c-! Return Pad, 0:=c as long Return Image1, 0!where:=Eval(Pad, 2) as byte, 0!where+1:=Eval(Pad, 1) as byte, 0!where+2:=Eval(Pad, 0) as byte } GetPixel=Lambda Image1,aLines=Len(Raster)-Len(Rasterline), blines=-Len(Rasterline) (x,y) ->{ where=alines+3*x+blines*y =color(Eval(image1, where+2 as byte), Eval(image1, where+1 as byte), Eval(image1, where as byte)) } StrDib$=Lambda$ Image1, Raster -> { =Eval$(Image1, 0, Len(Raster)) } CopyImage=Lambda Image1 (image$) -> { if left$(image$,12)=Eval$(Image1, 0, 24 ) Then { Return Image1, 0:=Image$ } Else Error "Can't Copy Image" } Export2File=Lambda Image1, x, y, r=len(rasterline) (f) -> { \\ use this between open and close Print #f, "P3" Print #f,"# Created using M2000 Interpreter" Print #f, x;" ";y Print #f, 255 x2=x-1 For y1= y-1 to 0 { a$="" where=24+r*y1 x1=0 Print #f, Eval(Image1, where +2 as byte);" "; Print #f, Eval(Image1, where+1 as byte);" "; Print #f, Eval(Image1, where as byte); where+=3 For x1=1 to x2 { Print #f, " ";Eval(Image1, where +2 as byte);" "; Print #f, Eval(Image1, where+1 as byte);" "; Print #f, Eval(Image1, where as byte); where+=3 } Print #f } } Group Bitmap { SetPixel=SetPixel GetPixel=GetPixel Image$=StrDib$ Copy=CopyImage ToFile=Export2File } =Bitmap } A=Bitmap(150,100) For i=0 to 98 { Call A.SetPixel(i, i, 5) Call A.SetPixel(99, i, color(128,0,255)) } Call A.SetPixel(i,i,0) Call A.SetPixel(30,50, color(128,0,255)) Print A.GetPixel(30,50)=color(128,0,255) move 3000, 3000 Image A.image$() profiler Open "A2.PPM" for Output as #F Call A.ToFile(F) Close #f print timecount } Checkit