Page 1 of 1

Detecting CurrentMovie (@Freak)

Posted: Mon Mar 28, 2005 7:57 pm
by Perni
Hi all together!
I'm very new to PB and this forum. I googled for the feature "Capture Screenshot from Movie" and found the absolute fantastic codeexample from Freak (posted at 04/23/2003).

Then I decide to buy PB and write my own VideoLibrary. All works very great with one exception:
The Capture-Routine makes the screenshot. Here is the codefragment:

Code: Select all

;capture the current frame and stores it into ImageData
Procedure.l CaptureFrame(MovieNumber, ImageNumber, MemoryBank) 
    Protected *Movie.PB_StructureMovie, *Video.IBasicVideo, *Window.IVideoWindow 
    Protected *ImageData.BITMAPINFOHEADER, DataSize, Parent, Result 
     
    !extrn _PB_Movie_ObjectsArea 
    !MOV eax, [_PB_Movie_ObjectsArea] 
    !MOV [esp+12], eax 
    
    *Movie  + MovieNumber * SizeOf(PB_StructureMovie)
    *Window = *Movie\Window 
    *Video  = *Movie\Video
    
    Result  = 0  
    If *Video\GetCurrentImage(@DataSize, 0) = #S_OK
        *ImageData = AllocateMemory(DataSize) 
        If *ImageData 
            If *Video\GetCurrentImage(@DataSize, *ImageData) = #S_OK 
                Result = SetDIBits_(0, UseImage(ImageNumber), 0, *ImageData\biHeight, *ImageData + *ImageData\biSize, *ImageData, #DIB_RGB_COLORS) 
            EndIf
            FreeMemory(MemoryBank) 
        EndIf
    EndIf
    ProcedureReturn Result 
EndProcedure
Obviously the routine should use the movie with MovieNumber. But definitely it uses always the Number = 0. I think, I have to change the ASM code. Unfortunately I don't understand assembler. :?
The original post from freak: viewtopic.php?t=9384&highlight=pbmovieobjectsarea

Greetings and many thanks in advance,
Perni

PS: At last I have to say: I'm really enthused about PureBasic. I came from VB6/VB.NET, but PB is much more easier. Already after spending a few hours, I'm able to create complex Solutions and compile Libraries. And the language has a lot of very mighty BuildIn-Commands. That's really great.

Posted: Mon Mar 28, 2005 10:41 pm
by freak
Since the #PB_Any feature was introduces (PB 3.80 ?) there is better way to access this
data structure than this asm code.

You should be able to change this code:

Code: Select all

    !extrn _PB_Movie_ObjectsArea
    !MOV eax, [_PB_Movie_ObjectsArea]
    !MOV [esp+12], eax
   
    *Movie  + MovieNumber * SizeOf(PB_StructureMovie) 
to this:

Code: Select all

    *Movie = IsMovie(MovieNumber)
This should also work with #PB_Any created movies then.
Sorry, I cannot test this right now.. please let me know if this works.

btw, the FreeMemory(MemoryBank) call is wrong.
Since there are no more any memorybank numbers, you have to free the memory
by the pointer you got when allocatin it. so it must be this:

Code: Select all

FreeMemory(*ImageData) 
Of course that makes the "MemoryBank" argument of the procedure obsolete.
This stuff was just needed in an older PB version.

Timo

That's it

Posted: Tue Mar 29, 2005 1:12 pm
by Perni
Hi freak.

Thank you for your fast answer. Yes, with exactly that changes it's working :lol:
In other words: The IsMovie() function returns a pointer to a PB_StructureMovie Structure. Very usefull.

My mistake was also, that I haven't used the constant #PB_ANY.

Thanks again and greetings,
Perni