sizeOf tImage returns 0

BlitzMax Forums/BlitzMax Beginners Area/sizeOf tImage returns 0

Is it possible to tell how big your images are in ram?

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


Wow thanks Tom. I'll use this function.

Will SizeOf work with sounds?

How should SizeOf be used?

SizeOf only returns the size of types. It has nothing to do with the actual data within, as the image or sound in a type is only a pointer.

oh.. thanks