Image overlays

Prev

Next

 






































































































Image overlays

Description

Image overlays over video frames

Overview

It is possible to overlay one or several images at the same time over the video frames (using more than one image overlay is enabled by the ImageOverlaySelector property described in this chapter).

The origin of the image can be:
- an image file
- a bitmap handle
- a TImage component (not available in OCX versions)
- a TBitmap component (not available in OCX versions)

For image files, the following format are supported:
BMP
GIF
JPEG
EXIF
PNG
TIFF
WMF
EMF
EMF+
EMF+ Dual

Unlike the logo, that is displayed in the video window when the component is not running, the image will be overlayed over the video frames when the component is previewing, recording or playing back.

Source of the image overlay

The image can be loaded from various image source formats by invoking:

A) straight method (overlay index passed as parameter):

SetImageOverlayFromImageFile2 (Index, filename): loads the overlay #index with the specified file image
SetImageOverlayFromHBitmap2 (Index, bitmapHandle): loads the overlay #index with the specified bitmap handle
SetImageOverlayFromTBitmap2: loads the overlay #index with the specified TBitmap Object (Delphi and C++Builder)
SetImageOverlayFromTImage2: loads the overlay #index with the specified TImage Object (Delphi and C++Builder)


B) image overlay selector method: (see Setting and retrieving the overlay properties)
- first set ImageOverlaySelector with the desired index to select the overlay
- then invoke one of the following functions:
SetImageOverlayFromImageFile (filename): loads the current overlay with the specified file image
SetImageOverlayFromHBitmap (bitmap handle): loads the current overlay with the specified bitmap handle
SetImageOverlayFromTBitmap (TBitmap object): loads the current overlay with the specified TBitmap Object (Delphi and C++Builder)
SetImageOverlayFromTImage(TImage object): loads the current overlay with the specified TImage Object (Delphi and C++Builder)



Activation/deactivation of the image overlay

The image overlay may be enabled or disabled on the fly by enabling or disabling SetImageOverlay_Enabled (index, value).

Location of the image overlay

The x,y location of the overlay over the video frames is specified by SetImageOverlay_LeftLocation and SetImageOverlay_LeftLocation.
ImageOverlay_LeftLocation must be in the [0..video width] range.
ImageOverlay_TopLocation must be in the [0..video height] range.

Size of the image overlay

The size to which the image will be stretched can be specified (in pixels) by SetImageOverlay_Width and SetImageOverlay_Height.
To use the real width of the image overlay set ImageOverlay_Width = -1
To use the real height of the image overlay set ImageOverlay_Height = -1

Stretching the image overlay to the video size

When SetImageOverlay_StretchToVideoSize is enabled, this property stretches the image overlay to the video size (in this case the image overlay location, width and height settings above are ignored)

Alpha-blending (semi-transparency)

The alphablending is enabled by SetImageOverlay_AlphaBlend.
The value of the alpha blending (in the [0..255] range) must be specified by SetImageOverlay_AlphaBlendValue.

Color-based transparency

The color-based transparency is enabled by SetImageOverlay_Transparent.
If SetImageOverlay_UseTransparentColor is disabled, the default color (background color) of the image is used.
If SetImageOverlay_UseTransparentColor is enabled, the color specified by SetImageOverlay_TransparentColorValue will be used.

Specifying all the properties at the time

You can invoke SetImageOverlayAttributes (instead of setting the image overlay properties one by one) to set all the settings above from a single function call.

Applying several image overlays concurrently

The ImageOverlaySelector property lets you use up to 1000 image overlays concurrently. This is just a theoritecal limit, the corresponding resources will be allocated only when you activate the corresponding selector.
You have just to specify the image overlay number before invoking SetImageOverlay... and ImageOverlayEnabled.

E.g.:

- loading and showing myimage1.gif:
ImageOverlaySelector = 0
SetImageOverlayFromAnyFile ("myimage1.gif")
ImageOverlayEnabled = true

- loading and showing myimage2.png at the (10, 20) location with a default size:
ImageOverlaySelector = 1
SetImageOverlayFromAnyFile ("myimage2.png")
ImageOverlay_LeftLocation = 10
ImageOverlay_TopLocation = 20
ImageOverlay_Width = -1
ImageOverlay_Height = -1
ImageOverlayEnabled = true

- hiding myimage1.gif
ImageOverlaySelector = 0
ImageOverlayEnabled = false

- modifying the location of myimage2.png at (40, 60) and resizing it at 120x90:
ImageOverlaySelector = 1
ImageOverlay_LeftLocation = 40
ImageOverlay_TopLocation = 50
ImageOverlay_Width = 120
ImageOverlay_Height = 90

- showing myimage1.gif semi-transparent
ImageOverlaySelector = 0
ImageOverlayEnabled = true
ImageOverlay_AlphaBlend = true
ImageOverlay_AlphaBlendValue = 140



See Also
GetPixelsDistance GetRGBPixelAt ImageOverlay_AlphaBlend ImageOverlay_AlphaBlendValue ImageOverlay_Height ImageOverlay_LeftLocation ImageOverlay_TopLocation ImageOverlay_Transparent ImageOverlay_TransparentColorValue ImageOverlay_UseTransparentColor ImageOverlay_Width ImageOverlayEnabled ImageOverlaySelector SetImageOverlay_AlphaBlend SetImageOverlay_AlphaBlendValue SetImageOverlay_ChromaKey SetImageOverlay_ChromaKeyLeewayPercent SetImageOverlay_ChromaKeyRGBColor SetImageOverlay_Enabled SetImageOverlay_Height SetImageOverlay_LeftLocation SetImageOverlay_RotationAngle SetImageOverlay_StretchToVideoSize SetImageOverlay_TargetDisplay SetImageOverlay_TopLocation SetImageOverlay_Transparent SetImageOverlay_TransparentColorValue SetImageOverlay_UseTransparentColor SetImageOverlay_Width SetImageOverlayFromBMPFile SetImageOverlayFromHBitmap SetImageOverlayFromHBitmap2 SetImageOverlayFromImageFile SetImageOverlayFromImageFile2 SetImageOverlayFromJPEGFile SetImageOverlayFromTBitmap SetImageOverlayFromTBitmap2 SetImageOverlayFromTImage SetImageOverlayFromTImage2