I have spent MONTHS working on this problem.
I am trying to create a program that will overlay a static text/image AND a moving text (like a ticker) on top of an existing video
I am using DirectshowNet with VMR-9
The issue is that the bitmap mixer of VMR9 requires a pointer to
alphaBitmap = New Bitmap(720, 256)
g= Graphics.FromImage(alphaBitmap)
Then I have a timer that executes several time per second and which scrolls the text as:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static Dim hr As Integer = 0
Static Dim vez = 0
The big issue is that each time the timer is called I am doing
surface = New Surface(device, alphaBitmap, Pool.SystemMemory)
and this is a huge overkill. If I leave the surface as global variable and do not make the above call , even if I update unmanagedSurface = surface.GetObjectByValue(DxMagicNumber) , Then there is no update of the image.
My question: is there a way to push by updated bitmap to the VMR9 mixer without requiring to create a new Direct3D everytime.
Note that only a small portion of the surface is modified everytime so I could replace only part of the surface…
So many thanks for anybody who could help
Guive
guivetemp@yahoo.com
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I could make good progress. But now I am facing the following issue:
When I try to overlay the text WITH LARGE FONTS ( I am writing a TV Application) on top of the window, the text quality is poor. I tried to play with texthintering and graph smooting parameter. but nothing makes. The perimeter of the text is always kind "dirty": sometimes even there is a connection between two adjacent letters.
any idea what could be going wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Which technology do you use to write your text (GDI or Direct3D) ?
GDI bitmaps don't support alpha values so colorkey is the only solution to do tansparency and this generaly produce very dirty things (especially with texts). Direct3D surfaces with alpha values & anti-aliased test generally produce better results.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i am a DirectShow newbie, so maybe my advice won't help. However i consider that you shouldn't create a new bitmap at each time the timer is called, only to change the destination rectangle of the VMR9AlphaBitmap. New bitmap should be created every time when the text is changing.
Hope it helps.
Regards,
Zollor.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So many thanks ! I translated the code in VB and managed to get it to work. I had to add however in the code
Static surface = New Surface(device, alphaBitmap, Pool.SystemMemory)
unmanagedSurface = surface.GetObjectByValue(DxMagicNumber)
You help was really really great. Without it, I would still be stuck !
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
Dim startTicks As Long = DateTime.Now.Ticks
Static Dim xcoord As Integer
However, don't forget that if you will resize the player window, you will have to reset the device and recreate the surface, at least this is how i could solve the device lost issue.
Regards,
Zollor.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have spent MONTHS working on this problem.
I am trying to create a program that will overlay a static text/image AND a moving text (like a ticker) on top of an existing video
I am using DirectshowNet with VMR-9
The issue is that the bitmap mixer of VMR9 requires a pointer to
alphaBitmap = New Bitmap(720, 256)
g= Graphics.FromImage(alphaBitmap)
Then I have a timer that executes several time per second and which scrolls the text as:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Static Dim hr As Integer = 0
Static Dim vez = 0
The big issue is that each time the timer is called I am doing
surface = New Surface(device, alphaBitmap, Pool.SystemMemory)
and this is a huge overkill. If I leave the surface as global variable and do not make the above call , even if I update unmanagedSurface = surface.GetObjectByValue(DxMagicNumber) , Then there is no update of the image.
My question: is there a way to push by updated bitmap to the VMR9 mixer without requiring to create a new Direct3D everytime.
Note that only a small portion of the surface is modified everytime so I could replace only part of the surface…
So many thanks for anybody who could help
Guive
guivetemp@yahoo.com
Zoltan,
I could make good progress. But now I am facing the following issue:
When I try to overlay the text WITH LARGE FONTS ( I am writing a TV Application) on top of the window, the text quality is poor. I tried to play with texthintering and graph smooting parameter. but nothing makes. The perimeter of the text is always kind "dirty": sometimes even there is a connection between two adjacent letters.
any idea what could be going wrong?
Hello Guive,
unfortunatly i don't know what may be the problem.
Best regards,
Zoltan.
Which technology do you use to write your text (GDI or Direct3D) ?
GDI bitmaps don't support alpha values so colorkey is the only solution to do tansparency and this generaly produce very dirty things (especially with texts). Direct3D surfaces with alpha values & anti-aliased test generally produce better results.
Hello Guivetemp,
i am a DirectShow newbie, so maybe my advice won't help. However i consider that you shouldn't create a new bitmap at each time the timer is called, only to change the destination rectangle of the VMR9AlphaBitmap. New bitmap should be created every time when the text is changing.
Hope it helps.
Regards,
Zollor.
Hello Guive,
i found a method to modify the bitmap without recreating the device. Please note that my example is in C#, but you can easily convert to VB.
private void _Timer_Tick(object sender, EventArgs e)
{
long startTicks = DateTime.Now.Ticks;
try
{
GraphicsStream stream = surface.LockRectangle(LockFlags.Discard);
The performance looks good.
Let me know if this helped...
Hi Zollor,
So many thanks ! I translated the code in VB and managed to get it to work. I had to add however in the code
Static surface = New Surface(device, alphaBitmap, Pool.SystemMemory)
unmanagedSurface = surface.GetObjectByValue(DxMagicNumber)
You help was really really great. Without it, I would still be stuck !
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
Dim startTicks As Long = DateTime.Now.Ticks
Static Dim xcoord As Integer
Hello Guive,
i am happy that i could help ;).
However, don't forget that if you will resize the player window, you will have to reset the device and recreate the surface, at least this is how i could solve the device lost issue.
Regards,
Zollor.
Aha !
This may explain why I get sometimes nullexceptions...