Code:
VAR
long zero[16]
PUB do_rects(rwidth, rheight, rx, ry, rdx, rdy, rbg, rfg) | row_size, row, char, i, j, pix
rwidth := rwidth #> 0 <# 512
rheight := rheight #> 0 <# 512
rx := rx #> 0 <# rwidth - 1
ry := ry #> 0 <# rheight - 1
rdx := rdx #> 0 <# rwidth - rx
rdy := rdy #> 0 <# rheight - ry
row_size := bitmap_header(rwidth, rheight, 1, @rbg)
repeat ry
server.array(@zero, row_size)
repeat rdy
repeat i from 0 to row_size - 1
repeat j from 0 to 7
pix := i << 3 + j
char := char << 1 - (pix => rx and pix < rx + rdx)
byte[@buffer][i] := char
server.array(@buffer, row_size)
repeat (rheight - ry - rdy)
server.array(@zero, row_size)
server.end_custom_content
PUB bitmap_header(img_width, img_height, bits_per_pixel, color_array) | i, j, colors, row_size
wrword_bytes(@bmp_width, img_width)
wrword_bytes(@bmp_height, img_height)
bmp_bitspp := bits_per_pixel
row_size := (bits_per_pixel * img_width + 31) >> 5 << 2
colors := 1 << bits_per_pixel
wrword_bytes(@bmp_data_addr, $1a + 3 * colors)
wrlong_bytes(@bmp_file_size, $1a + 3 * colors + row_size * ||img_height)
server.custom_content
server.array(@bmp_hdr, @bmp_hdr_end - @bmp_hdr)
repeat i from 0 to colors - 1
repeat j from 0 to 2
server.out(byte[color_array][i << 2 + j])
return row_size
PUB wrlong_bytes(addr, data)
wrword_bytes(addr, data)
wrword_bytes(addr + 2, data >> 16)
PUB wrword_bytes(addr, data)
byte[addr++] := data
byte[addr] := data >> 8
DAT
bmp_hdr byte "Content-type: image/bmp",EOL
byte "Cache-control: no-store",EOL,EOL
byte "BM"
bmp_file_size byte $4a,$18,0,0
byte 0,0,0,0
bmp_data_addr byte $4a,0
byte 0,0,$0c,0,0,0
bmp_width byte $80,0
bmp_height byte $60,0
byte $01,0
bmp_bitspp byte $04,0
bmp_hdr_end
The highlighted methods in the
Bookmarks