directx8 surfaces and win32 bitmaps

Started by
7 comments, last by bratsj 21 years, 7 months ago
Hey ! How do I get a directx8 surface into a standard win32 bitmap (HBITMAP) ? dx7 had some getDC function allowing for simple BitBlt, but I can''t find any counterpart for the (not very 2d-friendly) dx8 ... I''m brand new to this forum (so far I like it a lot) and want to apologize for posing such a trivial question thx :-)
Advertisement
HRESULT D3DXSaveSurfaceToFile(  LPCTSTR              pDestFile,  D3DXIMAGE_FILEFORMAT DestFormat,  LPDIRECT3DSURFACE8   pSrcSurface,  CONST PALETTEENTRY*  pSrcPalette,  CONST RECT*          pSrcRect);Maybe that''s what you''re looking for?    
quote:Original post by Bretttido

HRESULT D3DXSaveSurfaceToFile(
LPCTSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE8 pSrcSurface,
CONST PALETTEENTRY* pSrcPalette,
CONST RECT* pSrcRect
);
<br><br>Maybe that''s what you''re looking for? <hr height=1 noshade></SPAN></BLOCKQUOTE> <br><br>Thats for 3D inst it? dont u have to include 3D stuff then?<br><br> </pre>
ty, but no, that''s not what I''m seeking
I am not saving to file

The idea is to use the Direct3DX functions
D3DXLoadSurfaceFromFile
D3DXLoadSurfaceFromResource
to load such as .JPG images

But then comes the tricky part:
I do not want these images represented as D3D surfaces,
but as standard windows bitmaps

In other words, i''m looking for a function like

HBITMAP Convert_D3DSurface8_To_Win32Bitmap_Please (D3DSurface*);

There seem to be none however
So I''m looking for a substitute method

If there was some sort of DC (device context) handle
associated with a Directx8 surface (like DirectX7''s
surface.GetDC), the conversion would be easy (using
standard win32 BitBlt).

Is there?
Where? How? and Why not?



Perhaps you can save the surface to a file, load the newly created file with a bitmap routine, and then delete the file. lol... umm, I really don''t know how to get a device context so if you need a sloppy workaround, that may do.
I smiled when I read your creative approach
Your solution will definitely work ok
In fact, I might just go ahead ahead and do just that !

Ideally though I would like a method somewhat less
quobbelywobbelish - if such a thing does exist

ty :-)

Why don''t you lock the surface, get the bits, and then plot pixels onto the bitmap object''s dc.

---
My Site-My Tetris Clone w/Source
Come join us on IRC in #directxdev @ irc.afternet.org
Sounds great !!
Though I have no idea as to how to "get the bits"
In essence, that is my orignal question
If there is a relevant DX8 function call for "getting the bits",
please let me now. Thanx in advance

I want to say a few more words about my puzzle though:

I have always used the WIN32-methods for, say, maintaining
a background bitmap on a window. This works very nicely.
I have written my own event-hanlers for crucial events
such as WM_PAINT and WM_SIZE. Using the WIN32 BeginPaint and
EndPaint, windows itself maximizes redrawing efficiency through
keeping track of dirty regions and such
And the picture is Rock steady at all times !!

Well, so far so good. This is also the reason why I so need to
convert from DX8 Surface to WIN32 Bitmap (I really want to
benefit from the strong D3DXLoadSurface functions)

I have also tried to use DX8 "Present()-ing" for the above mentioned
scenario. Well, shouldn''t DirectX be fast !?
I put the device->Present() commando in the eventhandlers and tested.
It works all right. And it works horribly bad !
When f.inst moving a window on top of mine, DirectX cannot cope
with the WM_PAINT messages, and often areas are lost.

Ever wondered why windowed DX games halts when moving the window?
It is probably because the "game loop" is taking place in the
main window loop.
This can be easily fixed by writing an independent thread instead
But the problem still reamins:

If in need for ultraraoid 3d-graphics, DirectX is obviously good
But for maintaining rock-solid output on a window, the WIN32
mechanics seems to still prevail

All this cannot be a new dilemma
I would be thrilled to hear anyones thoughts on this topic


Ooops!

I took a closer look at surface::LockRect and its
D3DLOCKED_RECT structure. I think now I understand
what you meant :-)

If nothing else, the data can be copied bit for bit
by a simple loop. It might even be possible to get a
WIN32 bitmap to embrace the data directly and set up
a BitBlt.

I''ll check the related api function calls
This is jolly good fun

ty Stunna !


This topic is closed to new replies.

Advertisement