This should be fairly accurate. Although blitzmax strives to use the RGBA8888 format, in which case simply image.width * image.height * 4 * frameCount would give the amount of ram used, this is a safer way I think.
i:timage=CreateImage(800,600,10)
Print imagemem(i) 'all image frames
Print imagemem(i,4) 'just frame 4
Function ImageMem:Int(image:timage,frame:Int=-1)
Local p:tpixmap, mem:Int = 0, c:Int
If frame = -1
For c = 0 To image.frames.length-1
p = LockImage(image,c)
mem:+ p.pitch * p.height
UnlockImage(image,c)
Next
Return mem
Else
p = LockImage(image,frame)
mem = p.pitch * p.height
UnlockImage(image,frame)
End If
Return mem
End Function
|