timelzayus
New member
- Joined
- Aug 7, 2010
- Messages
- 10
- Reaction score
- 0
- Points
- 0
Hi all !
I have discovered Orbiter 2 weeks ago and I find it tremendous !
Being a developper, I thought I could develop a bit for Orbiter.
Here's my idea :
I would like to use MFDs in other PCs (especially my touch netbook). Currently, the only way to export MFDs over network has to be integrated in a ship, which is not very useful. I also tried solutions like VNC or MaxiVista with ExtMFD but there's alway the input problem : I can't touch / modify my external MFD and handle my ship in the same way as the coputer sees only one input.
Being a Web expert (HTML5 / Javascript and all) I figured : How about creating a plugin that would create a small web server (using the mongoose library) which would display the MFD and its button : there would be no need for a client, any web browser would do it. That would permit to have acces to the MFDs on any computer as well as on any tablet (like the iPad) or any othe device that has a web browser.
The thing is : I have troubles exporting the MFD display. I know it is possible : the module ExtMFD does it.
I am not bad in C/C++ (5 years of studying it) but I usually program only with cross-platform libraries (mainly with QT, boost, etc.) so I have absolutely no knowledge of MFC and GDI.
I have started a new module project copying the ExtMFD module sources.
The first step for me to do this module is to be able to export the MFD in a jpeg file (as I figured using the m-jpeg format over http would be a nice solution to display the MFD in a browser).
Here is what I have done so far : I have added a button marked "save" on the popup, this puts a bool save to true when it is clicked.
Then, I have added this code to the MFDWindow::RepaintDisplay method (my code is in red) :
It creates me a jpeg file, but the image is all black, nothing's on it.
I can't figure what I missed, could someone help me ?
I am completely stuck with this issue and I passed the entire afternoon reading the MSDN library, I could not find my mistake....
Thank you for helping !
I have discovered Orbiter 2 weeks ago and I find it tremendous !
Being a developper, I thought I could develop a bit for Orbiter.
Here's my idea :
I would like to use MFDs in other PCs (especially my touch netbook). Currently, the only way to export MFDs over network has to be integrated in a ship, which is not very useful. I also tried solutions like VNC or MaxiVista with ExtMFD but there's alway the input problem : I can't touch / modify my external MFD and handle my ship in the same way as the coputer sees only one input.
Being a Web expert (HTML5 / Javascript and all) I figured : How about creating a plugin that would create a small web server (using the mongoose library) which would display the MFD and its button : there would be no need for a client, any web browser would do it. That would permit to have acces to the MFDs on any computer as well as on any tablet (like the iPad) or any othe device that has a web browser.
The thing is : I have troubles exporting the MFD display. I know it is possible : the module ExtMFD does it.
I am not bad in C/C++ (5 years of studying it) but I usually program only with cross-platform libraries (mainly with QT, boost, etc.) so I have absolutely no knowledge of MFC and GDI.
I have started a new module project copying the ExtMFD module sources.
The first step for me to do this module is to be able to export the MFD in a jpeg file (as I figured using the m-jpeg format over http would be a nice solution to display the MFD in a browser).
Here is what I have done so far : I have added a button marked "save" on the popup, this puts a bool save to true when it is clicked.
Then, I have added this code to the MFDWindow::RepaintDisplay method (my code is in red) :
Code:
void MFDWindow::RepaintDisplay(HWND hWnd)
{
PAINTSTRUCT ps;
HDC hDCtgt = BeginPaint(hWnd, &ps);
SURFHANDLE surf = GetDisplaySurface();
if (surf)
{
HDC hDCsrc = oapiGetDC(surf);
BitBlt(hDCtgt, 0, 0, DW, DH, hDCsrc, 0, 0, SRCCOPY);
oapiReleaseDC(surf, hDCsrc);
[COLOR="Red"][B]if (save == true)
{
save = false;
using namespace Gdiplus;
Graphics* grph = Graphics::FromHDC(hDCtgt);
Bitmap bmp(DW, DH, grph);
CLSID clsid;
GetEncoderClsid(L"image/jpeg", &clsid);
bmp.Save(L"MFD.jpg", &clsid);
OutputDebugString("MFD SAVED\r\n");
delete grph;
}[/B][/COLOR]
}
else
{
SelectObject(hDCtgt, GetStockObject (BLACK_BRUSH));
Rectangle(hDCtgt, 0, 0, DW, DH);
}
EndPaint(hWnd, &ps);
}
I can't figure what I missed, could someone help me ?
I am completely stuck with this issue and I passed the entire afternoon reading the MSDN library, I could not find my mistake....
Thank you for helping !