Page 1 of 1

Simple OSD tutorial

Posted: Tue Feb 12, 2008 2:00 pm
by rel
Hello, based on some requests from users, I've decided to write some simple tutorials for the programming of OSD, EPG and Channel List on DD.
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;
After creating the surface, we should use another command to display it, DDMODAPI_OSD_SHOW_SURFACE.


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);
Notes
- OSD doesn't support transparency at the moment.

Posted: Thu Jun 03, 2010 2:28 pm
by dashne
Iwant to show a bitmap image on osd by c++ can one tell me the procedures and function to do that

Re: Simple OSD tutorial

Posted: Thu Dec 01, 2011 12:59 pm
by rel
here is the source code of DDOSD , as an example with latest SDK header

Re: Simple OSD tutorial

Posted: Tue May 21, 2013 6:21 am
by zixi0007
Could you please tell me how to create and destroy OSD with C++ or give me a sample? Because I don't know about delphi. Many thanks.

Re: Simple OSD tutorial

Posted: Fri May 24, 2013 8:03 am
by rel
Could you please tell me how to create and destroy OSD with C++ or give me a sample? Because I don't know about delphi. Many thanks.
There is no example for C++ but it shouldn't be difficult ,
Use GDI Windows API to handle / draw on BITMAPs and assign them to DD OSD with module API.

Re: Simple OSD tutorial

Posted: Wed Sep 25, 2013 10:27 pm
by zixi0007
I still can not solve this problem, My boss please to give a c++ OSD example.
:( :( :( :(