You can get frames from source objects (MFReader or MFLive), but also you can create a new frame independently from any source. To do it you should use the MFFactory object.
With this object, you can create new frames from files, from bitmaps or from memory.
Create a frame from file
You should use the MFFrameCreateFromFile method to create a frame from a local file. It is useful for example to use such frame for digital signature (channel logo overlay).
This method contains the following parameters:
- _bsFileName - path to source file (JPEG, PNG, BMP or TIFF image),
- _ppFrame - result frame,
- _bsPropsList - additional properties. The property is reserved for future usage.
For example:
MFFactoryClass frameFactory = new MFFactoryClass(); MFFrame frameFromFile; string pathToFile = @"c:\myLogo.png"; frameFactory.MFFrameCreateFromFile(pathToFile, out frameFromFile, "");
Create a frame from memory
Also if you have a frame in memory and you get a pointer and information about a frame, you can create a frame from memory directly with MFFrameCreateFromMem.
This method contains the following parameters:
- _pAVProps - media properties for a frame
- _lpVideo - pointer to video data
- _lAudioSamples - number of audio samples
- _lpAudio - pointer to audio data
- _ppFrame - result frame
- _bsPropsList - additional properties.
You can create a frame of a required size and other media properties using pointers to audio and video data.
This method is also useful to create simple frames the fastest way, for example, transparent frames of solid color frames. To create a simple frame you should call:
M_AV_PROPS frameProps = new M_AV_PROPS(); frameProps.vidProps.eVideoFormat = eMVideoFormat.eMVF_HD1080_5994i;
frameProps.vidProps.fccType = eMFCC.eMFCC_ARGB32; //set the ARGB32 format if you need a transparent frame MFFactory factory = new MFFactoryClass(); MFFrame createdFrame; string colorParameters = "solid_color='Red(255)'"; factory.MFFrameCreateFromMem(ref frameProps, 0, 0, 0, out createdFrame, colorParameters);
where you set required video format for a new frame. colorParameters has this structure:
solid_color='[color]([transparency])'
where color is a name ('red') or ARGB code ('FFAACCEE') and transparency has a value between 0 (full transparency) and 255 (solid color).
Create a frame from bitmap
Bitmap objects, that are used in application controls, contain HBitmap property. You can create a new frame from this property with the MFFrameCreateFromHBITMAP method.
This method contains the following parameters:
- _hBitmap - a handle of source bitmap,
- _ppFrame - result frame,
- _bsPropsList - additional properties. The property is reserved for future usage.
For example, you may use canvas control in Delphi, where you can draw any lines. You can get HBitmap of this control to create a frame and then use a newly created frame to overlay a source frame.