[Windows Mobile]Draw Text on preview or SampleGrabber and DirectShow.NETCF
If you ever used DirectShow under windows then you know that if you want draw text on preview you can use VMRRenderer, but windows mobile dont provide any way to draw text on preview
I see there only 1 way to solve it - Draw text directly on stream, so we need SampleGrabber to got access to raw stream, also we need to create our own font (thats the main problem). i made small demo that allows draw text on preview.
So IGetFrame was modified:
[ComVisible(true), ComImport,
Guid("2B21644A-D405-4E27-A51C-A4812bE0CE4C"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IGetFrame
{
[PreserveSig]
int getFrame(IntPtr pBuff);
[PreserveSig]
int getSize([Out] out long size);
[PreserveSig]
int getFrameParams(
[Out] out int width,
[Out] out int height,
[Out] out RawFrameFormat format);
[PreserveSig]
int drawText(
[In] IntPtr ptr,
[In] int height,
[In] int width);
[PreserveSig]
int stopDraw();
}
As you can see we got new method: drawText([In] IntPtr ptr, [In] int height, [In] int width);
where ptr - is our text in special format…
how to conver text to IntPtr?
there added extra class: CABC, here is example how to draw text:
CABC abc = new CABC("abcd dabc cdab bcda");
frmGrabber.drawText(abc.getText(), abc.Height, abc.Width);
abc.Dispose();
abc = null;
Also you can check AMCamera example from DirectShowNETCF
Filed under: Programming
September 8th, 2009 at 2:53 pm
Hi Alex,
~ Great Job ~
It is possible to draw a rectangle.