![]() |
Multimedia »
Audio and Video »
DirectShow
Intermediate
License: The Code Project Open License (CPOL)
Procamp for directshow.NetBy Jarno BurgerHow to use use brightness contrast saturation hue in your directshow.net filtergraph |
VB (VB 7.x, VB 8.0, VB 9.0, VB 6), .NET (.NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5), DirectX, CEO, Architect, DBA, Dev, QA, Design
|
||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
I am starting out multiple articles that will describe parts of how to use DirectShow.Net.
When i have finished with enough examples , i will combine them into a total videoplayer program , written in VB.NET.
This article will explain how to extend your filtergrpah to use the ProcAmp control.
The ProcAmp is a really cool thing , lets make your movie all the colors of the rainbow !
I am using the directshow.net libary , it lets you build directshow stuff in vb.net / c#.
Be aware , not all filtergraph's support this trick.
The if then code-part tries to catch that..
Please create a filtergraph first.
I only give a example for brightness here , but with some extra lines of code , but hue , contrast , saturation works the same.
This part of code is placed behind your .renderstream function. is a VideoMixingRenderer9 object (that is part of my filtergraph)
f_VideoMixing_Renderer
f_VideoMixerProcampControl is a control (VMR9ProcAmpControl) that gives you acces to colorizing your video
f_VideoMixerProcampRange (VMR9ProcAmpControlRange) is the object that you put in , and get out of your procamp control . You always have to marshal.sizeof when getting/setting something in your procamp.
'************************************* video procamp *********************************************
'new setup mixer control
Dim f_VideoMixerControl As IVMRMixerControl9 = CType(f_VideoMixingRenderer, IVMRMixerControl9)
DsError.ThrowExceptionForHR(hr)
'new setup procamp control
Dim f_VideoMixerProcampControl As VMR9ProcAmpControl
f_VideoMixerProcampControl.dwSize = Marshal.SizeOf(f_VideoMixerProcampControl)
f_VideoMixerProcampControl.dwFlags = 0
hr = f_VideoMixerControl.GetProcAmpControl(0, f_VideoMixerProcampControl)
DsError.ThrowExceptionForHR(hr)
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Brightness) > 0 Then
Debug.WriteLine("brightness")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Contrast) > 0 Then
Debug.WriteLine("constrast")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Hue) > 0 Then
Debug.WriteLine("hue")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Mask) > 0 Then
Debug.WriteLine("mask")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.None) > 0 Then
Debug.WriteLine("none")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Saturation) > 0 Then
Debug.WriteLine("saturation")
End If
'get procamp control range for brightness
Dim f_VideoMixerProcampRange As VMR9ProcAmpControlRange
f_VideoMixerProcampRange.dwProperty = VMR9ProcAmpControlFlags.Brightness
f_VideoMixerProcampRange.dwSize = Marshal.SizeOf(f_VideoMixerProcampRange)
hr = f_VideoMixerControl.GetProcAmpControlRange(0,f_VideoMixerProcampRange)
DsError.ThrowExceptionForHR(hr)
'set the brightness in ProcAmp , tell that the size has changed
Dim brightpos As Double = 0.1
f_VideoMixerProcampControl.Brightness = CSng(f_VideoMixerProcampRange.MinValue + brightpos * (f_VideoMixerProcampRange.MaxValue - f_VideoMixerProcampRange.MinValue))
'set the new value in ProcAmp to the videomixercontrol
f_VideoMixerProcampControl.dwSize = Marshal.SizeOf(f_VideoMixerProcampControl)
hr = f_VideoMixerControl.SetProcAmpControl(0, f_VideoMixerProcampControl)
DsError.ThrowExceptionForHR(hr)
It took me 2 years to learn vb.net , half year to learn directshow . and half a day to do ProcAmp. You have to go and read about every command i used if you are a newbie to this.
Tis is the first version of this code..
| You must Sign In to use this message board. | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
|
||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 14 Feb 2008 Editor: |
Copyright 2008 by Jarno Burger Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |