Skip to main content
GameDev.net gamedev.net
🔒 Locked

Saving Screenshots to Bitmap

Started by monkey-poop Dec 6, 2001 at 2:21 PM 6 replies 200+ views
Original Post
monkey-poop
monkey-poop
Hello, I made a function for my DirectX 6 engine that takes a picture of the screen and saves it to a bitmap file. I tested it on a simple unsigned char* buffer that I created and it worked. I want to copy the primary buffer to the bitmap buffer, but it always crashes when I do that. I know it''s not the function itself, because as I said it works for a unsigned char* buffer. I have 3 questions: 1.) Are there any tutorials or examples on the internet on how to create screenshots with DirectDraw? 2.) Which buffer should I copy to the bitmap? I would assume that it would be the primary buffer, because the back buffer is half written by the time the mainloop reads the screenshot key. 3.) Is this code correct: unsigned char *buffer = (unsigned char *)PrimarySurface(); inline LPDIRECTDRAWSURFACE4 PrimarySurface() { return m_lpddsprimary; } And do I have to lock the primary surface before copying from it? Thanks for your time, Jon
ByteMe95
ByteMe95
First of all I hope you know that you can just use the PrintScreen key for DX games to get a screen shot, then paste it into a paint program.

But anyway, you definately have to lock the primary buffer in order to copy from it
And dont forget to account for pWidth, the primary surface pWidth might not be it''s actual width, so dont forget!

ByteMe95::~ByteMe95()
Cerebrum Software
ByteMe95::~ByteMe95()My S(h)ite
ByteMe95
ByteMe95
First of all I hope you know that you can just use the PrintScreen key for DX games to get a screen shot, then paste it into a paint program.

But anyway, you definately have to lock the primary buffer in order to copy from it
And dont forget to account for pWidth, the primary surface pWidth might not be it''s actual width, so dont forget!
Actually, I meant pitch, not pWidth
oops

ByteMe95::~ByteMe95()
Cerebrum Software
ByteMe95::~ByteMe95()My S(h)ite
monkey-poop
monkey-poop
Yeah, I know, but the clipboard horribly garbles the image. I don''t know why....
monkey-poop
monkey-poop
My application is in 16 bit mode.
monkey-poop
monkey-poop
Thanks for the link, your website is very nice.

I couldn''t seem to find the tutorial you were talking about on the Tricks page. What is its title?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.