Images
Supported file formats for overlay are PNG, JPG, BMP, TIFF, TGA.
To add an image as an overlay you should use a path to your file with the AddNewItem method:
string graphicsItemId = "myImage"; string pathToImageFile = @"c:\logo.png"; double relativeX = 0.05; double relativeY = 0.05; int isRelative = 1; int isShow = 1; myCharGen.AddNewItem(pathToImageFile, relativeX, relativeY, isRelative, isShow, ref graphicsItemId);
Default XML description of the image item looks like:
<cg-item id='myImage'> <img path='C:\logo.png'/> <cg-props pos-x='36' pos-y='24' show='yes' move-type='accel-both' alpha='255' bg-color='Black(0)' pixel-ar='0.' play-mode='loop' interlace='auto' scale='fit-ar' align='top-left' width='167' height='51' pause='no' edges-smooth='0'> <indent left='0' right='0' top='0' bottom='0' use-for-bg='no'/> <group-indent left='0' right='0' top='0' bottom='0'/> </cg-props> </cg-item>
Specific properties for images are set in <img> node.
Property | Description | Values | Example |
---|---|---|---|
border | thickness of border around the image | thickness in pixels | border='5'![]() |
color | a color of the border around the image | color according to Color settings | color='red'![]() |
image.ignorear | indicates whether aspect ratio of image will be ignored | true/false | image.ignorear='true'![]() |
Also, you can get information whether the image loaded correct or not (for example if a file doesn't exist). If item can't be loaded there will be "load_error" property in <img> node with "true" value.
To check this you can call:
try { string itemID = "image-000"; string propertyName = "img::load_error"; string loadErrorValue; myCharGen.GetItemProperties(itemID, propertyName, out loadErrorValue); } catch (Exception) { // the exception raises if there is no load_error property that means image is loaded correctly }
Image sequences
You can use sequences of files as single overlay item. To use image sequences you should set a path to a folder where your files are placed and a mask to filter files in the AddNewItem method.
string graphicsItemId = "myImageSequence"; // to add only PNG files string pathToFlashFile = @"c:\myFolder\*.png"; double relativeX = 0.05; double relativeY = 0.05; int isRelative = 1; int isShow = 1; myCharGen.AddNewItem(pathToFlashFile, relativeX, relativeY, isRelative, isShow, ref graphicsItemId);
To add a file mask to the sequence you should use wild-card expression in a file name, for example:
string pathToFlashFile = @"c:\myImages\big_buck_bunny_*.png";
The images are used in alphabetical order so check the names of your images to be sure in playback order.
You can specify for image sequences the same properties as for single image. Also, you can set in- and out-points for the sequence to limit the number of frames. To do it you should set 'frame-in' and 'frame-out' properties. For example:
<img path='c:\myFolder\*.png' frame-in='5' frame-out='26'/>
frame-out is calculated from the end of all items. So in the example above the sequence is over with NumberOfImages-26 image.
Video files
It is possible to use video files in Character Generator as an overlay. Since the CG is a graphics engine, you can't use audio data from the files to mix it with the main video.
string graphicsItemId = "myImageSequence"; // to add a sample video file string pathToFlashFile = @"c:\myVideo.mp4"; double relativeX = 0.05; double relativeY = 0.05; int isRelative = 1; int isShow = 1; myCharGen.AddNewItem(pathToFlashFile, relativeX, relativeY, isRelative, isShow, ref graphicsItemId);
You can use videos with transparency (alpha channel) for smooth animation (as an alternative to flash overlays).
You can trim control the video file with the following ways:
- Start playback - just display the item with ShowItem method.
- Pause playback - PauseItem method. With the same method, you can resume playback.
- Stop - specify 'play-mode' property for the item to required one ("loop" for loop playback, "onetime" to play just once and stop on the last frame, "onetime-hide" to play just once and hide once it is over)
- Set in- and out-points - set "in" and "out" attributes for item like
<img path='C:\myVideo.mp4' in='10' out='20' open_props='' border='0' color='white(255)'/> - Specify different properties with "open_props" attribute. You can use the same properties available for FileNameSet and ReaderOpen methods.