Jump to content
Sign in to follow this  
SirJohann

Help with frames per second

Recommended Posts

SirJohann
Hi guys! Just a little question. I need to calculate the frames per second for a GDI animation. I made a little script, at least I have the seconds per frame, but I don't know how continue:
 
Global $iTimerNewFrame = 0, $iTimerLastFrame = 0, $iTimerDiff = 0

Global $iTimer = _Timer_Init()

while 1
$iTimerNewFrame = _Timer_Diff($iTimer)
$iTimerDiff = Round(($iTimerNewFrame - $iTimerLastFrame) / 1000, 2) ;This returns the difference(seconds per frame)
$iTimerLastFrame = $iTimerNewFrame
wend

This works perfect, now I must with that value calculate the frames per second, but I'm really lost and when I look in google I find solutions in C++, and I still don't know anything about C++. 

Of course, when I use round sometimes I loss some values, so if there is another way to delete all the numbers that returns _Timer_Diff. I was thinking about using @MSEC, but I don't really like macros, I'm not sure about them.


Codes codes codes.

Share this post


Link to post
Share on other sites
Valuater

Not sure just where you are going with that...

But here is some great work from two pros!

'?do=embed' frameborder='0' data-embedContent>>

and later...

'?do=embed' frameborder='0' data-embedContent>>

These get into DLL calls with frames per second and etc.

 
; monoceres, Prog@ndy
Func _CreateAvi($sFilename, $FrameRate, $Width, $Height, $BitCount=24)
    Local $RetArr[5] ; avi file handle, stream handle, bitmap count, BitmapInfoheader, Stride
   
    Local $ret, $pfile, $asi, $pstream
   
    $ret = DllCall($Avi32_Dll, "int", "AVIFileOpenW", "ptr*", 0, "wstr", $sFilename, "uint", $OF_CREATE, "ptr", 0)
    $pfile = $ret[1]
   
   
    $asi = DllStructCreate($AVISTREAMINFO)
    DllStructSetData($asi, "fccType", $streamtypeVIDEO)
    DllStructSetData($asi, "fccHandler", $mmioFOURCC_M_S_V_C)
    DllStructSetData($asi, "dwScale", 1)
    DllStructSetData($asi, "dwRate", $FrameRate)
    DllStructSetData($asi, "dwQuality", 10000)
    DllStructSetData($asi, "rright", $Width)
    DllStructSetData($asi, "rbottom", $Height)
   
    $ret = DllCall($Avi32_Dll, "int", "AVIFileCreateStream", "ptr", $pfile, "ptr*", 0, "ptr", DllStructGetPtr($asi))
 
    $pstream = $ret[2]
   
    Local $stride = BitAND(($Width * ($BitCount / 8) + 3) ,BitNOT(3))
   
    Local $bi = DllStructCreate($BITMAPINFOHEADER)
    DllStructSetData($bi,"biSize",DllStructGetSize($bi))
    DllStructSetData($bi,"biWidth",$Width)
    DllStructSetData($bi,"biHeight",$Height)
    DllStructSetData($bi,"biPlanes",1)
    DllStructSetData($bi,"biBitCount",$BitCount)
    DllStructSetData($bi,"biSizeImage",$stride*$Height)
 
    ; The format for the stream is the same as BITMAPINFOHEADER
    $ret = DllCall($Avi32_Dll, "int", "AVIStreamSetFormat", "ptr", $pstream, "long", 0, "ptr", DllStructGetPtr($bi), "long", DllStructGetSize($bi))
   
    $RetArr[0] = $pfile
    $RetArr[1] = $pstream
    $RetArr[2]=0
    $RetArr[3]= $bi
    $RetArr[4]= $stride
    Return $RetArr
EndFunc

NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.