It's something like this...
width = whatever
Height = whatever
set display mode width, height, 32
sync on: sync rate 60: sync
colour as dword
set bitmap format 21
x = 0
y = 0
colour = point(x, y)
rgbTotal = rgbr(colour) + rgbg(colour) + rgbb(colour)
dot x, y, set alpha(colour, 255 * (rgbTotal > 0))
sync
get image 1, 0, 0, width + 1, height + 1, 3
save image "test.png", 1
end
... but may need experimenting with. The important parts are...
set bitmap format 21... which should retain alpha transparency. I have picked just the top corner of the image as the transparent colour, but you may want more transparency, which means that you might have to pick colours from the entire image.
Anyway I got it from Green Gandalf in this thread...
http://forum.thegamecreators.com/?m=forum_view&t=159714&b=1
Which is a more complete version.