#### Archived

This topic is now archived and is closed to further replies.

# directx8 surfaces and win32 bitmaps

This topic is 5759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 :-)

##### Share on other sites
HRESULT D3DXSaveSurfaceToFile(  LPCTSTR              pDestFile,  D3DXIMAGE_FILEFORMAT DestFormat,  LPDIRECT3DSURFACE8   pSrcSurface,  CONST PALETTEENTRY*  pSrcPalette,  CONST RECT*          pSrcRect);Maybe that''s what you''re looking for?



##### Share on other sites
quote:
Original post by Bretttido
HRESULT D3DXSaveSurfaceToFile(  LPCTSTR              pDestFile,  D3DXIMAGE_FILEFORMAT DestFormat,  LPDIRECT3DSURFACE8   pSrcSurface,  CONST PALETTEENTRY*  pSrcPalette,  CONST RECT*          pSrcRect);[code]Maybe that''s what you''re looking for?

Thats for 3D inst it? dont u have to include 3D stuff then?

##### Share on other sites
ty, but no, that''s not what I''m seeking
I am not saving to file

The idea is to use the Direct3DX functions
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

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?

##### Share on other sites
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.

##### Share on other sites
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 :-)

##### Share on other sites
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

##### Share on other sites
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",

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.
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

##### Share on other sites
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 !

• 17
• 11
• 12
• 9
• 49
• ### Forum Statistics

• Total Topics
631395
• Total Posts
2999757
×