Main Menu

Calc Used Image Memory

Started by kevin, June 08, 2008, 08:38:51 AM

Previous topic - Next topic

kevin

 CalcUsedImageMemory

This little useful debug function calculates the total size (in bytes) of the PB image + Screen buffers.

This version is for PB V1.63 and bellow.

PlayBASIC Code: [Select]
; **=------------------------------------------------------------------=*
; >> Calc Used Image Memory <<
; **=------------------------------------------------------------------=*
;
; This _debug_ function runs through the PB image list and returns the
; total number of bytes images are using. Due to the buffer locking it's
; not going to fast, so don't call it every frame !
;
; **=------------------------------------------------------------------=*


Function CalcUsedImageMemory()
OldSurface=GetSurface()

For Img=0 to GetImageQuantity()
If Img=0 or GetImageStatus(Img)=true
Rendertoimage Img
Lockbuffer
ImgSize= GetImagePitch(Img)*GetIMageHeight(img)
unlockbuffer

// Check for screen. If so, add the second buffer
if Img=0 then ImgSize=ImgSize*2
Memory=Memory+ImgSize
Endif
next

RenderToImage OldSurface
EndFunction Memory