framebuffer to bitmap file

Started by
4 comments, last by Nurgle 19 years, 8 months ago
I am using Lock on a DirectDraw front buffer to draw pixels to the screen. I need to capture a screenshot and write it to a file. I have tried to configure directx to capture the screen when prntscrn is pressed but it doesn't work (maybe because I'm writing directly to the front buffer??) So i have a pointer to an array of size 640x480, with 24 bit pixels. All I need to do is write this to a bitmap. When I try to google an answer I get stuff that deals with DC GDI stuff, and say"all you need is a DC context or something" Well i'm not familiar at all with gdi stuff and I have trouble if I try to implement this stuff. Can somebody please help me out with this.
~EODCyismARDEM
Advertisement
There is a way to get a DC from a DirectDraw Surface, can't quite remember how. Check out DDUtil.cpp and DDUtil.h.
- I don't pretend to know anything.Snowsoft
Actually I looked it up and GetDC is a function inside the Surface object. So you can use lpDDSurface->GetDC(hDC).
- I don't pretend to know anything.Snowsoft
Slightly OT, but why the hell are you writing directly to the front buffer? Surely it'd be better to write to the back buffer then flip?

After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming

Thanks alot Smack0007, GetDC was exactly what I needed.

For people that possibly search this post in the future, This page: http://www.geocities.com/foetsch/screenshot/screenshot.htm solved my problem. It has a code listing on the bottom that takes a screenshot from a directdraw buffer.

Nurgle: I write to a backbuffer but then bitblt to the front, rather than flip. Thats what I meant by writing to the frontbuffer, I guess I was a little misleading.
~EODCyismARDEM
Hmmm... I think you really want to flip instead of blit... (I'm a poet and I wasn't aware of the fact)



Technically, blitting is just changing the starting address of the video buffer, where as blitting involves copying the memory, ergo, flip=faster. I'm not sure if modern cards still do this, but that's how it used to be in the good ol' days of Mode 13H.

After careful deliberation, I have come to the conclusion that Nazrix is not cool. I am sorry for any inconvienience my previous mistake may have caused. We now return you to the original programming

This topic is closed to new replies.

Advertisement