Advertisement

Easiest way to get a directdrawsurface into a bitmap

Started by December 01, 2000 01:37 PM
6 comments, last by Fresh 24 years, 1 month ago
What''s the easiest way to get a directdrawsurface into a bitmap file? I would assume you would use a windows function somewhere along the line, but I can''t quite figure it out (and I have a headache . So does anybody offhand know? - and even better provide a source listing :?) r. "The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
In lamothes book tips of the game programming gurus he has some code on the cd that takes a bitmap and copies it to a surface. Sorry I dont have the code on here I dont have it all memorized yet. But I will try and post it on here later.
Advertisement
I''m not trying to load a bitmap, but to save a surface to a file...
r. (I''ve got my loading functions working fine

"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
Lock() the surface
Copy the memory
Get the palette if its 8 bit
Unlock() the surface
Save the file

Check the DirectX manual, it actually has useful information in it!

Bulbasaur



----------
meh
----------meh
Sorry, I''m probably not making myself clear enough - I want to save a ddsurface to a bitmap file, not just the memory it contains. I was wondering whether I''m going to have to do everything manually, or I can do something like use the gdi to save it, which will handle all the semantics for me.
r.

"The mere thought hadn''t even begun to speculate about the slightest possibility of traversing the eternal wasteland that is my mind..."
Try CDX a class library for DirectX, it has the capability and is open source so you ought to be able to grab what you need from that.

jack
Advertisement
There''s another almost identical post floating about with other answers.
You could also use the FreeImage library and save your surface as JPG, PNG, TGA etc. as well as BMP
The memory contained in the surface is in the bitmap format (actually so is gdi and just about everything else involving simple graphic output and memory), you need only fill in the bitmap header, the bitmap info header, and if you need one, the palette.
Why use a windows function when you have the opportunity here to learn a whole lot about graphic output? Put something in that eternal wasteland that is your mind

Good luck,

-Bulbasaur



----------
meh
----------meh

This topic is closed to new replies.

Advertisement