API Question Getting a HBITMAP from a SURFHANDLE

timelzayus

New member
Joined
Aug 7, 2010
Messages
10
Reaction score
0
Points
0
Hi all !
I am currently writing an extension that permits to export MFDs over network.
It's working !
To do that, I need to get a HBITMAP from a SURFHANDLE. I do that with a BitBlt :
Code:
	HDC hDCsrc = oapiGetDC(_surface);

	// Copy the Device Context into a Bitmap
	HDC cdc = CreateCompatibleDC(hDCsrc);
	HBITMAP cbm = CreateCompatibleBitmap(hDCsrc, Width(), Height());
	HBITMAP oldbm = (HBITMAP)SelectObject(cdc, cbm);
	BitBlt(cdc, 0, 0, Width(), Height(), hDCsrc, 0, 0, SRCCOPY);
	SelectObject(cdc, oldbm);

	// Release the Surface Device Context
	oapiReleaseDC(_surface, hDCsrc);
There is a big problem on that code : The BitBlt. It does not use the hardware acceleration and is VERY slow. Currently, Orbiter is not very usable with my plugin *only* because of this BitBlt.
I need another way to get a HBITMAP or a GDI+ CImage from a oapi::SURFHANDLE.
A friend and I have been searching for two days and we did not found... maybe someone could help me ?

Thank you very much.
 
Doesn't quite answer your question, but forum member whitewatcher did exactly this some time ago. His original post was here, and you can continue in that thread to see a discussion of how it works.

He also offered some more info about it here, and linked to his thesis and code samples here.

We should probably see if we can get in touch with him and ask him to publish his addon...
 
Last edited:
Please... Help !
This really is the only thing preventing me from doing a kick-ass plugin !
I can't find a way to transform a SURFHANDLE to a HBITMAP without destroying the framerate... Even in a thread, it doesn't help....
 
Si je tape ces deux mots dans google, je tombe sur des liens concernant orbiter, dansteph bien sûr et ici, mais aussi sur un forum moins connu, élite game, d'où proviennent parfois des réalisations intéressantes faites par la communauté russe, russophone, pour ce qui concerne orbiter.

Sur le lien qui suit sont présents entre autres Igel et Thorton. Le premier dont j'ai déjà lu des messages ici et surtout Thorton qui viens très régulièrement.

Tout est en cyrillique mais peut être qu'en passant un message dans la boite de courrier, ici, de Thorton...

http://www.elite-games.ru/conference/viewtopic.php?p=1778590&sid=e4c7c0951c20675d16713d95857ff4f8

Et/ou peut être Face ?
 
Last edited:
I assume you're on either Vista or Win7?

What graphics card are you using? If you're on Win7, if you can find WDDM 1.1 drivers for your card, this should allow BitBlt to be hardware-accelerated. The majority of GDI calls aren't hardware-accelerated as of Vista--you might want to look into Direct2D and see if it has an answer for you.
 
Last edited:
It's not a driver problems.
Lags and loss of FPS has been reported by all users of my add-on...
I really need to get a mnipulable image out of the surfhandle. I am stuck... I hate that ! :p
 
It's not a driver problems.
Lags and loss of FPS has been reported by all users of my add-on...
I really need to get a mnipulable image out of the surfhandle. I am stuck... I hate that ! :p

If the BitBlt really turns out to be the show stopper, you can always try to split the Blitting over more than one time-step. I.e. blit scan-lines or blocks into a buffer and compose the image later on. As soon as I have my compiler setup running, I'll see what I can do...

regards,
Face
 
have you considered trying Device-Independent bitmaps?
you can get a handle to a image bits structure from GetDIBits or have it fill up a buffer for you...

don't know if it helps much... would be easier to give out advice if you provided some more details on what you're trying to do and exactly why it doesn't work :hmm:

here's a list of GDI functions... maybe there's something in there that can be of use (although you might probably have seen that already)


also, if still feel you gotta "go GPU" - have a look at these DirectDraw interface functions.... DirectDraw is the part of DirectX that does GDI-ish things on the GPU (i believe) - it's probably gonna be a bit of a hurdle to get it going, but it should get things running smoother for you
 
Last edited:
also, if still feel you gotta "go GPU" - have a look at these DirectDraw interface functions.... DirectDraw is the part of DirectX that does GDI-ish things on the GPU (i believe) - it's probably gonna be a bit of a hurdle to get it going, but it should get things running smoother for you
DirectDraw has been deprecated since DirectX 7--you may want to look into Direct2D instead.
 
Back
Top