Jump to content

How to create a Video Overlay GUI (GDIPlus)


Recommended Posts

Hi Community,

I'm looking for a way to do a Video Overlay GUI or something like that. The idea is to create a GUI which plays a video loop (with transparency/alpha channel) in front of an other GUI. Before you asking why - because I don't believe that GDIPlus can do it out of the box. My skillset for that kind of graphical things isn't good enough to do that, but here are some specialist like @UEZ maybe ;) who can help.


Example alpha channel video (visualized as animated *.gif):


I tried to do the light rays effect directly with GDIPlus, but honestly that's a bit too difficult for me. I would be very glad and grateful if there are some suggestions, ideas or recommendations.


Code for the Video play:

Spoiler
Func _mpegVideoOpen( $sFile, $hWnd, $iW, $iH, $iX, $iY )
    Local $iHandleId  = Dec( StringTrimLeft( $hWnd, 2 ) )
    Local $sVideoName = ''

    For $i = 1 To 10 Step 1
        $sVideoName &= Chr( Random( 97, 122, 1 ) )
    Next

    _mciSendStringA( 'open ' & FileGetShortName( $sFile ) & ' alias ' & $sVideoName )
    _mciSendStringA( 'window ' & $sVideoName & ' handle ' & $iHandleId )
    _mciSendStringA( 'put ' & $sVideoName & ' destination at ' & $iX & ' ' & $iY & ' ' & $iW & ' ' & $iH )

    Return $sVideoName
EndFunc

Func _mciSendStringA( $string, $iLenght = 0 )
    Return DllCall( 'winmm.dll', 'int', 'mciSendStringA', 'str', $string, 'str', '', 'long', $iLenght, 'long', 0 )[2]
EndFunc

Func _mpegVideoPlay( $sVideoName, $bFullscreen = False )
    If _mpegVideoTimePos( $sVideoName ) == _mpegVideoLength( $sVideoName ) Then _mpegVideoSeek( $sVideoName, 'start' )

    If $bFullscreen Then
        _mciSendStringA( 'play ' & $sVideoName & ' fullscreen' )
    Else
        _mciSendStringA( 'play ' & $sVideoName )
    EndIf
EndFunc

Func _mpegVideoTimePos( $sVideoName )
    _mciSendStringA( 'set ' & $sVideoName & ' time format ms' )
    Return _mciSendStringA( 'status ' & $sVideoName & ' position', 255 )
EndFunc

Func _mpegVideoLength( $sVideoName )
    _mciSendStringA( 'set ' & $sVideoName & ' time format ms' )
    Return _mciSendStringA( 'status ' & $sVideoName & ' length', 255 )
EndFunc

Func _mpegVideoSeek( $sVideoName, $sStartOrEnd )
    _mciSendStringA( 'set ' & $sVideoName & ' time format ms' )
    Return _mciSendStringA( 'seek ' & $sVideoName & ' to ' & $sStartOrEnd )
EndFunc

Func _mpegVideoStatus( $sVideoName )
    Return _mciSendStringA( 'status ' & $sVideoName & ' mode', 255 )
EndFunc

Func _mpegVideoClose( ByRef $sVideoName )
    Return _mciSendStringA( 'close ' & $sVideoName )
EndFunc

Func _mpegVideoPlayAndClose( $sFileVideo )
    Local $sVideoName = _mpegVideoOpen( $sFileVideo, $hMainGui, $iWGui, $iHGui, $iXGui, $iYGui )

    _mpegVideoPlay( $sVideoName )

    While 1
        If _mpegVideoStatus( $sVideoName ) == 'stopped' Then
            _mpegVideoClose( $sVideoName )
            ExitLoop
        EndIf
    WEnd
EndFunc

_mpegVideoPlayAndClose( 'End.mpeg' )

 

 

Example video "End.mpeg":

Spoiler

I provide this video as an example but this isn't an alpha channel video, so please be not confused ;) .

http://sven-seyfert.de/news/End.mpeg

 

The next challenge is that the overlay GUI should be not clickable. If I hover over the overlay area, I want to have the possibility to control the GUI or what ever, in the background. But if there is any chance to make it with GDIPlus as a Video Overlay for light rays, I would prefer that approach instead of my crazy work-around idea.

Thanks for any suggestion - I'm grateful!
Sven

Edited by Sven-Seyfert
Link to comment
Share on other sites

Maybe I should explain that I want to use it in my 2D game. It should improve the game ambience a lot.

Otherwise I tried to change the brightness and contrast of the background tiles (the images), but it didn't work and it would look not very good.

Is there any other possibility to deal with such effects in an game? Other recommended third party tools that should be used? But I like GDIPlus and I don't wanna work with Irrlicht for example.

Any help, suggestion, recommendation and ideas are welcome.

Thanks - I'm grateful!
Sven

Link to comment
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
 Share

×
×
  • Create New...