Click here to Skip to main content
6,306,412 members and growing! (17,406 online)
Email Password   helpLost your password?
Multimedia » Audio and Video » DirectShow     Intermediate License: The Code Project Open License (CPOL)

Procamp for directshow.Net

By Jarno Burger

How 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
Posted:7 Feb 2008
Updated:14 Feb 2008
Views:9,250
Bookmarked:16 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
3 votes for this article.
Popularity: 0.48 Rating: 1.00 out of 5
3 votes, 100.0%
1

2

3

4

5

Introduction

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..

Using the code

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.

f_VideoMixing_Renderer
is a VideoMixingRenderer9 object (that is part of my filtergraph)

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)

Points of Interest

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.

History

Tis is the first version of this code..

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jarno Burger


Member
Jarno Burger
i am videojockey for festivals.
i am getting fed up with the vj programs at the moment , so i am trying to go and write my own one.

if you wanna read some more stuff about directshow.net , then you can read some chunks of info on my blog , with some extra handy links to more articles and forums.

http://jarnoburger.blogspot.com/

Occupation: Other
Location: Netherlands Netherlands

Other popular Audio and Video articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralProcamp - Could you please send the source code? PinmemberRoms19:00 15 Feb '08  
GeneralRe: Procamp - Could you please send the source code? PinmemberJarno Burger0:26 20 Feb '08  
GeneralRe: Procamp - Could you please send the source code? PinmemberNoctris12:10 15 Jul '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 14 Feb 2008
Editor:
Copyright 2008 by Jarno Burger
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project