Archived

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

Bits to DirectX surface

This topic is 5586 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

Hi, I was wondering if there was a way to write a pointer of BYTES obtained: LPBYTE lpDIB = (LPBYTE) GlobalLock( hBitmap ); directly to a directx surface. The hBitmap is defined as a HBITMAP, but it is however a DIB. If not what is the best way for me to write the DIB to a directx surface? Thanks Marcus de Leon

Share this post


Link to post
Share on other sites
(a) create a texture
(b) render a quad

Alternatively, use the sprite class provided.

Direct access - IMHO not.


Regards

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
or sometimes In My Honest Opinion
with no Humbleness implied ;-)

Share this post


Link to post
Share on other sites
Lock the target surface, and write pixel-by-pixel, converting the pixel format as you go. (most likely, you won't have a B8G8R8 format for the surface)
Edit:
oh and unlock it when you're done

- JQ
Full Speed Games. Coming soon.

[edited by - JonnyQuest on August 29, 2002 10:04:38 AM]

Share this post


Link to post
Share on other sites
How fast will writing pixel by pixel to a surface be?

Here is my overall problem. I am getting a HBITMAP as a DIB from a third party dll. Right now I am writing the HBITMAP info to a HDC using the StretchDIBits function (Can''t use BitBlt b/c it''s a DIB). The HDC is then written to a back buffer in DirectX. Then the back buffer is flipped and the graphic is displayed. These graphics are tiles for a tile based world.

This is really slow. What is the easiest way to speed this up?

NOTE: I''m also fairly new at this type of programming.

Thanks in advance.

Share this post


Link to post
Share on other sites
The best way is to convert the bitmap once - copy & convert it to an offscreen plane with the same PixelFormat as the backbuffer, and do all blitting from there to the backbuffer. Won''t get much faster than that

- JQ
Full Speed Games. Coming soon.

Share this post


Link to post
Share on other sites