Advertisement

Q: LPDIRECTDRAWSURFACE->HBITMAP

Started by January 18, 2000 01:19 AM
3 comments, last by RMZ 24 years, 11 months ago
I want to copy the image in LPDIRECTDRAWSURFACE into HBITMAP I know it's possible to copy image in HBITMAP into LPDIRECTDRAWSURFACE..(we use this to load BMP image into LPDIRECTDRAWSURFACE) but how about the reverse? how to do it? if anyone knows plz give me the answer. Edited by - RMZ on 1/18/00 2:14:33 AM
When you load an HBITMAP onto an LPDIRECTDRAWSURFACE (if you''re using the DDUtils.cpp functions) all you''re doing is calling a StretchBlt onto the GDI surface (if I''m not wrong). So, all you should have to do to copy the dd surface to the HBITMAP is get the GDI surface (I believe the call is ddSurface->FlipToGDISurface() or something like that) and then call StretchBlt or BitBlt on it, blitting it to an HDC or CDC (in MFC) that you have associated with your HBITMAP. But I haven''t done much straight Windows programming, so I might not be entirely accurate...

------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge
Advertisement
Here is how I did it, and I think it is a slightly easier way than Qoy's method (no offense)

I used the LPDIRECTDRAWSURFACE->GetDC() function to lock the surface and get its DC. Then you can get the DC of the destination bitmap (do it the same way you would when loading a bitmap to a surface). Then use BitBlt() (that is BitBlt, the Win32 api function, not Blt the Direct Draw function)

Once you've done that, release the two DCs, and you're done.
LPDIRECTDRAWSURFACE->ReleaseDC()

-Omalacon

Edited by - Omalacon on 1/19/00 12:07:59 AM
Yes, that is a better way. I think my reasoning was skewed. I had forgotten that you could get a DC from a surface.
Thanks for anwer you guys~ ^_^

This topic is closed to new replies.

Advertisement