Here is the first tutorial, OSD. I hope you will find it quite easy to play with.
DVB Dream OSD API Tutorial
OSD consists of the surfaces placed on the video at given coordinates.
Surfaces are simply the rectangles that you can place anywhere on the OSD space.
OSD space has 1024 x 768 pixels and always has a fixed aspect ratio on the video.
How to create an OSD surface ?
An OSD surface is created using DDMODAPI_OSD_CREATE_SURFACE command.
Following sample creates a 500 x 80 surface on the x:80, y:80 coordinates.
Code: Select all
var
surface: TOSDSurface; // surface properties
hSurface1: Integer; // surface handle
begin
surface.dwSize := sizeof(surface);
surface.dwLeft := 80;
surface.dwTop := 80;
surface.dwWidth := 500;
surface.dwHeight := 80;
surface.Transparency := TRANSPARENCY_LEVEL1;
hSurface1 := SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_CREATE_SURFACE, Integer(@surface));
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_SHOW_SURFACE, hSurface1);
end;
How to paint on an OSD surface
As you can see, the surface we've created is simply an empty black box. So we will need to use other commands to be able draw on this box.
DDMODAPI_OSD_GET_SURFACE_BITMAP and DDMODAPI_OSD_REPAINT_SURFACE
Code: Select all
var
...
hbmSurface1: HBITMAP; // bitmap handle for the surface
bm: TBitmap; // delphi object to easily draw on the bitmap
begin
...
hbmSurface1 := SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_GET_SURFACE_BITMAP, hSurface1);
bm := TBitmap.Create;
bm.Handle := hbmSurface1;
bm.Canvas.Brush.Color := clBlue;
bm.Canvas.FillRect(Rect(0, 0, 30, bm.Height));
bm.Canvas.Brush.Style := bsClear;
bm.Canvas.Brush.Color := clNone;
bm.Canvas.Font.Color := clWhite;
bm.Canvas.Font.Name := 'Tahoma';
bm.Canvas.Font.Style := [fsBold];
bm.Canvas.Font.Size := 24;
bm.Canvas.TextOut(40, 3, 'Hello There!');
bm.ReleaseHandle;
bm.Free;
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_REPAINT_SURFACE, hSurface1);
end;
How to hide an OSD surface
Code: Select all
SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_HIDE_SURFACE, hSurface1);
How to destroy an OSD surface
Code: Select all
hSurface1 := SendMessage(hwndDD, WM_MODULE_MSG, DDMODAPI_OSD_DESTROY_SURFACE, hSurface1);
- OSD doesn't support transparency at the moment.