Jump to content
  • Advertisement

Archived

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

bratsj

directx8 surfaces and win32 bitmaps

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

HRESULT D3DXSaveSurfaceToFile(
LPCTSTR pDestFile,
D3DXIMAGE_FILEFORMAT DestFormat,
LPDIRECT3DSURFACE8 pSrcSurface,
CONST PALETTEENTRY* pSrcPalette,
CONST RECT* pSrcRect
);


Maybe that''s what you''re looking for?

Share this post


Link to post
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 this post


Link to post
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
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?



Share this post


Link to post
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 this post


Link to post
Share on other sites
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 :-)

Share this post


Link to post
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",
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


Share this post


Link to post
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 !


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!