
Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
Hi Bob
Thanks for replying! yes you guessed it right I am using same bitma
rather than creating new bitmap every few seconds. Hence probably i
wouldnt be good idea to dispose bitmap
as long as overlay needs to be shown. Any how I am posting some bit o
code
PHP code
-------------------
namespace Overlays
{
public class Overlay
{
public String overlayText;
public Color overlayTextColor;
public Color overlayBackgroundColor;
public String text;
private IVideoWindow vw;
private IVMRMixerBitmap9 mbmp;
Bitmap masterBmp = null;
Font fon = null;
private ArrayList arrayGuru;
float alpha = 0;
public Overlay(IVideoWindow vw, IVMRMixerBitmap9 mbmp)
{
this.vw = vw;
this.mbmp = mbmp;
System.Console.WriteLine("I am in OverlayCS Constructor");
masterBmp = new Bitmap(750, 500, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
masterBmp.MakeTransparent(Color.White);
// InitializeDirect3D();
}
public void OffOverlay()
{
VMR9AlphaBitmap alphaBmp;
alphaBmp = new VMR9AlphaBitmap();
int hr = mbmp.GetAlphaBitmapParameters(out alphaBmp);
Marshal.GetExceptionForHR(hr);
// Disable them
alphaBmp.dwFlags =VMR9AlphaBitmapFlags.Disable;
// Update the Alpha Bitmap Parameters
hr = mbmp.UpdateAlphaBitmapParameters(ref alphaBmp);
Marshal.GetExceptionForHR(hr);
//masterG
}
public void OnOverlay(ArrayList arrList,
int distBetwSubRect,
int distance,
float alpha,
int indexToBeHighlighted,
string Action)
{
Graphics g = null;
IntPtr hdc;
IntPtr memDC ;
IntPtr hBitmap ;
Bitmap bmp = null;
VMR9AlphaBitmap alphaBmp;
alphaBmp = new VMR9AlphaBitmap();
this.alpha = alpha;
try
{
int hr = 0;
arrayGuru=arrList;
//GetBitmap();
g = Graphics.FromImage(masterBmp);
//g.Clear(Color.White);
Navigate(indexToBeHighlighted, distBetwSubRect, distance);
hdc = g.GetHdc();
memDC = NativeMethodes.CreateCompatibleDC(hdc);
hBitmap = masterBmp.GetHbitmap();
NativeMethodes.SelectObject(memDC, hBitmap);
// Set Alpha Bitmap Parameters for using a GDI DC
alphaBmp.dwFlags = VMR9AlphaBitmapFlags.hDC |
VMR9AlphaBitmapFlags.SrcColorKey |
VMR9AlphaBitmapFlags.FilterMode;
alphaBmp.hdc = memDC;
alphaBmp.rSrc = new Foundation.Base.DShowNET.Default.DsRect(0, 0, masterBmp.Width, masterBmp.Height);
alphaBmp.rDest = GetDestRectangle();
alphaBmp.clrSrcKey = ColorTranslator.ToWin32(Color.White);
alphaBmp.dwFilterMode = Foundation.Base.DShowNET.Default.VMRMixerPrefs.PointFiltering;
alphaBmp.fAlpha = alpha;
// Release GDI handles
hr = mbmp.SetAlphaBitmap(ref alphaBmp);
g.ReleaseHdc(hdc);
g.Dispose();
}
catch (Exception ex)
{
}
finally
{
//bmp.Dispose();
// bmp = null;
g.Dispose();
g = null;
GC.Collect();
}
}
NormalizedRect GetDestRectangle()
{
NormalizedRect rect = new NormalizedRect();
//rect.left =0.2f;
//rect.top =0.1f;
//rect.right = 0.9f;
//rect.bottom = 0.3f;
rect.left = 0.0f;
rect.top = 0.0f;
rect.right = 1.0f;
rect.bottom = 0.7f;
return rect;
}
private void Nav(int indexToBeHighlighted, int distBetwSubRect, int distance)
{
try
{
int y = 0;
Graphics g = Graphics.FromImage(masterBmp);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
//VMR9AlphaBitmap alphaBmp;
//alphaBmp = new VMR9AlphaBitmap();
for (int i = 0; i <= 5; i++)
{
if (i == indexToBeHighlighted)
{
g.DrawRectangle(Pens.Blue, new Rectangle(distance, y, 300, 50));//250
g.FillRectangle(Brushes.Black, new Rectangle(distance, y, 300, 50));
using(Font fon = new Font("Courier",18))
g.DrawString(arrayGuru[i].ToString(),fon , Brushes.Blue, (distance + 25), (y+2));//275
y = y + distanceBetweenSubtitleRectangles;//150
}
else
{
g.DrawRectangle(Pens.WhiteSmoke, new Rectangle(distance, y, 300, 50));//250
g.FillRectangle(Brushes.Black, new Rectangle(distance, y, 300, 50));
using(Font fon = new Font("Courier",18))
g.DrawString(arrayGuru[i].ToString(), fon, Brushes.WhiteSmoke, (distance + 25), (y+2));//275
y = y + distanceBetweenSubtitleRectangles;//150
}
}
g.Dispose();
}
catch(Exception ex)
{
}
}
}
}
--------------------
regds
TheIlliterate

Signature
TheIlliterate
TheIlliterate - 26 Oct 2005 05:44 GMT
Hey no suggestions at all !? :
--
TheIlliterat