I wrote some memblock bitmap functions a while ago that may help you:
remstart
-------------------------------------------------------------------
program name: Memblock Bitmap Functions
-------------------------------------------------------------------
written by: Oli Burt
date: 6th April 2009 - 9th April 2009
-------------------------------------------------------------------
comments:
-------------------------------------------------------------------
remend
set display mode 640,480,32
hide mouse
sync on
mbbmp_make(1,640,480,32)
mbbmp_clear(1,rgb(255,255,255))
mbbmp_box(1,200,100,300,250,rgb(255,0,0))
mbbmp_line(1,20,300,400,260,rgb(0,255,0))
for i = 0 to 200
x=rnd(639) : y=rnd(479)
mbbmp_dot(1,x,y,rgb(0,255,255))
next i
make bitmap from memblock 1,1
copy bitmap 1,0
sync
wait key
delete memblock 1
end
`--------------
` Functions
`--------------
Function mbbmp_box(memblock,ax,ay,bx,by,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
for y = ay to by
for x = ax to bx
write memblock dword memblock,12+(x+y*width)*byte_depth, colour
next x
next x
Endfunction
`//
Function mbbmp_make(memblock,width,height,bit_depth)
if memblock exist(memblock) = 0
byte_depth= bit_depth/8
make memblock memblock,12+width*height*byte_depth^2
`Header (12 bytes)
write memblock dword memblock,0,width
write memblock dword memblock,4,height
write memblock dword memblock,8,bit_depth
endif
Endfunction
`//
Function mbbmp_dot(memblock,x,y,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
write memblock dword memblock,12+(x+y*width)*byte_depth, colour
Endfunction
`//
Function mbbmp_clear(memblock,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
for y = 0 to height-1
for x = 0 to width-1
write memblock dword memblock,12+(x+y*width)*byte_depth, colour
next x
next y
Endfunction
`//
Function mbbmp_line(memblock,ax,ay,bx,by,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Get Line Length (Hypotenuse of x/y triangle)
xdif= ax-bx
ydif= ay-by
hyp= sqrt(xdif*xdif + ydif*ydif)
`Edit Memblock
for pass = 1 to hyp
factor#= pass/(hyp*1.0)
x= ax - int((ax-bx)*factor#+.5)
y= ay - int((ay-by)*factor#+.5)
write memblock dword memblock,12+(x+y*width)*byte_depth, colour
next pass
Endfunction
`//
Function mbbmp_point(memblock,x,y)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Read From Memblock
colour = memblock dword(memblock,12+(x+y*width)*byte_depth)
Endfunction colour
`//
The gluteus-maximus mammary-gland formally known as OBese87.