(as a follow on from my previous snippet with bob.bmp)
Far from pixel perfect of course.
Code: Select all
'shells
'ld -r -b binary -o bob.o bob.bmp
'ar rcs -o libbob.a bob.o
#inclib "bob"
screen 20,32
Function reverse(Byref im As ulong Ptr) As Any Ptr
#define ppset(_x,_y,colour) *Cptr(Ulong Ptr,row+ (_y)*pitch+ (_x) Shl 2) =(colour)
#define ppoint(_x,_y) *Cptr(Ulong Ptr,row + (_y)*pitch + (_x) Shl 2)
Dim As Integer pitch
Dim As Any Ptr row
Dim As Ulong Ptr pixel
Dim As Integer dx,dy,sz
Imageinfo im,dx,dy,,pitch,row,sz
' ' leopard's way...
dx -= 1 : dy -= 1
dim as ulong tempclr
For y As Integer=0 To dy
For x As Integer=0 To int(dx)\2
tempclr = ppoint(x,y)
ppset (x,y,ppoint((dx)-x,y))
ppset((dx)-x,y,tempclr)
Next x
Next y
Return im
End Function
function bmpload(s as string) as ulong ptr
static as ulong ptr u:u=new ulong[len(s)-1]
u[0]=7
u[1]=4
u[2]=*cast(ulong ptr,@s[18])
u[3]=*cast(ulong ptr,@s[22])
u[4]=(u[2]*4)
u[5]=0
u[6]=0
u[7]=0
dim as long ctr=7,ls=len(s)
var k=iif(u[2] mod 16=0,1,0)
for n as long=8 to len(s)+6 step 3+k
ctr+=1
u[ctr]=*cast(ulong ptr,@s[55-k+n])
next
ctr-=7
u=reverse(u)
for n as long=8 to ctr\2 -7
swap u[n],u[ctr-n]
next
return u
end function
extern bob_bmp_start alias "_binary_bob_bmp_start" as byte
extern bob_bmp_end alias "_binary_bob_bmp_end" as byte
dim ub as ubyte ptr
dim ub_length as long
ub = @bob_bmp_start
ub_length = @bob_bmp_end - @bob_bmp_start
dim as long ctr
dim as string s=string(ub_length,0)
for n as ubyte ptr=(@bob_bmp_start) to (@bob_bmp_end)
s[ctr]=*n
ctr+=1
next
put(0,0),bmpload(s),pset
sleep