Simple OSD tutorial

Module API help / support section for programmers.

Moderators:Dreamer, FredB, X05

User avatar
rel
relocation
Posts:2051
Joined:Fri Jun 16, 2006 9:50 am
Simple OSD tutorial

Postby rel » Tue Feb 12, 2008 2:00 pm

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.
Attachments
SimpleOSD_Delphi.rar
Delphi Sample
(179.26KiB)Downloaded 1434 times

DVB Dream - because I have to dream about having time to code it
dashne
Just can't stay away
Posts:20
Joined:Thu Jun 03, 2010 2:25 pm

Postby dashne » Thu Jun 03, 2010 2:28 pm

Iwant to show a bitmap image on osd by c++ can one tell me the procedures and function to do that
skystar2
User avatar
rel
relocation
Posts:2051
Joined:Fri Jun 16, 2006 9:50 am

Re: Simple OSD tutorial

Postby rel » Thu Dec 01, 2011 12:59 pm

here is the source code of DDOSD , as an example with latest SDK header
Attachments
ddosd (for sdk).rar
example code in delphi (with latest SDK header files)
(96.55KiB)Downloaded 1148 times
DVB Dream - because I have to dream about having time to code it
zixi0007
Just popping in
Posts:4
Joined:Tue May 21, 2013 6:08 am

Re: Simple OSD tutorial

Postby zixi0007 » Tue May 21, 2013 6:21 am

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.
User avatar
rel
relocation
Posts:2051
Joined:Fri Jun 16, 2006 9:50 am

Re: Simple OSD tutorial

Postby rel » Fri May 24, 2013 8:03 am

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.
DVB Dream - because I have to dream about having time to code it
zixi0007
Just popping in
Posts:4
Joined:Tue May 21, 2013 6:08 am

Re: Simple OSD tutorial

Postby zixi0007 » Wed Sep 25, 2013 10:27 pm

I still can not solve this problem, My boss please to give a c++ OSD example.
:( :( :( :(

Return to “Module / Plugin Programming”

Who is online

Users browsing this forum: No registered users and 0 guests