31 lines
711 B
Plaintext
31 lines
711 B
Plaintext
Width% = 200
|
|
Height% = 200
|
|
|
|
VDU 23,22,Width%;Height%;8,16,16,128
|
|
*display c:\lena
|
|
|
|
f% = OPENOUT("c:\lena.ppm")
|
|
IF f%=0 ERROR 100, "Failed to open output file"
|
|
BPUT #f%, "P6"
|
|
BPUT #f%, "# Created using BBC BASIC"
|
|
BPUT #f%, STR$(Width%) + " " +STR$(Height%)
|
|
BPUT #f%, "255"
|
|
|
|
FOR y% = Height%-1 TO 0 STEP -1
|
|
FOR x% = 0 TO Width%-1
|
|
rgb% = FNgetpixel(x%,y%)
|
|
BPUT #f%, rgb% >> 16
|
|
BPUT #f%, (rgb% >> 8) AND &FF
|
|
BPUT #f%, rgb% AND &FF
|
|
NEXT
|
|
NEXT y%
|
|
CLOSE#f%
|
|
|
|
END
|
|
|
|
DEF FNgetpixel(x%,y%)
|
|
LOCAL col%
|
|
col% = TINT(x%*2,y%*2)
|
|
SWAP ?^col%,?(^col%+2)
|
|
= col%
|