sizeOf tImage returns 0

BlitzMax Forums/BlitzMax Beginners Area/sizeOf tImage returns 0

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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