Hi, everyone, Iwant to load a bitmap file into an osd and how I can add text on it like channel information ,Iam using mvc++,anyone can help?!!
thanks
loading abitmap file into an osd with c++
Moderators:X05, Dreamer, FredB
DD will create a bitmap handle (HBITMAP) when youcreate an OSD surface and you can pass it to GDI API functions.
http://www.toymaker.info/Games/html/gdi.html
check the section named "Displaying Text"
I think, you can use BitBlt() to place a bitmap on another bitmap (OSD surface for example).
http://www.toymaker.info/Games/html/gdi.html
check the section named "Displaying Text"
I think, you can use BitBlt() to place a bitmap on another bitmap (OSD surface for example).
DVB Dream - because I have to dream about having time to code it
It's relatively simple if you already know how to use GDI calls.
Following code uses WTL classes for GDI functions, but you can easily change it to pure Win32 GDI calls.
First tell DD to create bitmap for you and get HBITMAP for it. Also create DC for drawing.
When you want to update OSD, use function like this:
I call function like this that fills all info on event, like channel or volume change.
For every surface, I have "changed" and "visible" state, so I'm updating only surfaces that really needs to be updated.
Finally on module unload, destroy dcSurface and also DD surface by DDMODAPI_OSD_DESTROY_SURFACE.
Following code uses WTL classes for GDI functions, but you can easily change it to pure Win32 GDI calls.
First tell DD to create bitmap for you and get HBITMAP for it. Also create DC for drawing.
Code: Select all
// Global variables
HBITMAP bmSurface;
int surface_id;
CDC dcSurface;
CRect rcSurface;
void InitOSD()
{
CRect rc(10,10,200,50); // Rectangle for OSD surface
TOSDSurface surface = {
sizeof(TOSDSurface),
rc.left,rc.top,rc.Width(),rc.Height();
TRANSPARENCY_NONE
};
rcSurface = CRect(0,0,rc.Width(),rc.Height()); // so we dont need to calculate this every time...
surface_id = SendMessage(m_hWndDream, WM_MODULE_MSG, DDMODAPI_OSD_CREATE_SURFACE, (LPARAM)&surface); // create surface
bmSurface = (HBITMAP)SendMessage(m_hWndDream, WM_MODULE_MSG, DDMODAPI_OSD_GET_SURFACE_BITMAP, surface_id); // get bitmap
dcSurface.CreateCompatibleDC(NULL); // create screen compatible DC
}
Code: Select all
void UpdateOSD()
{
HBITMAP oldbm = dcSurface.SelectBitmap(bmSurface);
/// here you can use dcSurface for any painting, drawing text and other stuff ///
dcSurface.FillSolidRect(rcSurface,RGB(50,50,50));
// If you want to draw bitmap, use code like this:
{
CDC bdc;
bdc.CreateCompatibleDC(dcSurface);
HBITMAP pOldBmp = bdc.SelectBitmap(some_bitmap_you_have_loaded);
dcSurface.BitBlt(0,0,bitmap_width,bitmap_height,bdc,0,0,SRCCOPY); // Change pos/size as needed...
pdc.SelectBitmap(pOldBmp);
}
dcSurface.SelectBitmap(oldbm); // Important -> de-select bitmap before calling DD API
SendMessage(m_hWndDream, WM_MODULE_MSG, DDMODAPI_OSD_REPAINT_SURFACE, surface_id);
SendMessage(m_hWndDream, WM_MODULE_MSG, DDMODAPI_OSD_SHOW_SURFACE, surface_id);
// Show surface, you need to call this only once
}
For every surface, I have "changed" and "visible" state, so I'm updating only surfaces that really needs to be updated.
Finally on module unload, destroy dcSurface and also DD surface by DDMODAPI_OSD_DESTROY_SURFACE.
Skystar2 2.3 + Skystar HD2 + SG-2100 + TwinLNB
I failed
Hi,guys
thank you for your replies,when I compiled your code I got an error message :
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
when I exclude the windows.h from the code I get more than 100 error
please help me ,if you can upload acomplete project for these particular problems ?
thanks.
thank you for your replies,when I compiled your code I got an error message :
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
when I exclude the windows.h from the code I get more than 100 error
please help me ,if you can upload acomplete project for these particular problems ?
thanks.
skystar2
Here are all important includes:
stdafx.h:
stdafx.cpp:
plugin.cpp:
stdafx.h/cpp is for precompiled headers, plugin.cpp is main program file.
CAppModule is used by WTL when creating new windows and dialogs, you may not need it if you have none in your plugin.
Note that I'm using no MFC headers, it's all ATL + WTL. (ATL is part of Microsoft Platform SDK, WTL can be downloaded from SourceForge).
stdafx.h:
Code: Select all
#if !defined(AFX_STDAFX_H_)
#define AFX_STDAFX_H_
#include <atlbase.h>
#include <atlapp.h>
extern CAppModule _Module;
#include <atlcrack.h>
#include <atlwin.h>
#include <atldlgs.h>
#include <atlmisc.h>
#include "..\Include\moduleAPI.h" // Dream SDK API
#endif
Code: Select all
#include "stdafx.h"
#if (_ATL_VER < 0x0700)
#include <atlimpl.cpp>
#endif //(_ATL_VER < 0x0700)
BOOL __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /* lpReserved */)
{
switch (dwReason) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
_Module.Init(0, hInstance);
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
_Module.Term();
break;
}
return TRUE;
}
Code: Select all
#include "stdafx.h"
#include "resource.h"
#include <atlframe.h>
#include <atlctrls.h>
#include <atldlgs.h>
#include <atlctrlw.h>
#include <atlctrlx.h>
#include <atlmisc.h>
CAppModule _Module;
...
CAppModule is used by WTL when creating new windows and dialogs, you may not need it if you have none in your plugin.
Note that I'm using no MFC headers, it's all ATL + WTL. (ATL is part of Microsoft Platform SDK, WTL can be downloaded from SourceForge).
Skystar2 2.3 + Skystar HD2 + SG-2100 + TwinLNB
I failed again
Hi agin I failed,I exactly used the code but this time cmpilation is ok,but dvbdream didnt show me anything,can you upload plugin.cpp code completely to know where should I put the functions,Iam so sorry for anoying but I just have you for helping
thanks.
thanks.
skystar2
image loading
Hi again,thank you so much for your help,but I have aproblem with loading the image(bitmap) ,Iam loading it with function 'LoadImage(...)'
but the the return value is error code 2 which means the specified file does not exis but I have this file and it is inthe same directory of the plugin,H do not know what is the problem?
thanks
but the the return value is error code 2 which means the specified file does not exis but I have this file and it is inthe same directory of the plugin,H do not know what is the problem?
thanks
skystar2
Return to “Module / Plugin Programming”
Who is online
Users browsing this forum: No registered users and 1 guest