Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Saving a DDSurface to .bmp file

Posted on 2000-02-24
7
Medium Priority
?
272 Views
Last Modified: 2012-08-14
I curently building a game developping tool that use DirectDraw and VB, it's near completion, the last thing left is the saving feature that will take a DirectDraw surface and save it to the disk.  I search the web, all my books and ask on many message board, but no one has reply me with something I could use.  I really need an answer it's the sixth day I'm on this problem.

Thank you.
0
Comment
Question by:Kayan
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
pjknibbs earned 225 total points
ID: 2554418
I don't think there's any easy way to do this. The method I once used (albeit in C, not VB) went as follows:

1) Get a device context for the DD surface using GetDC().
2) Create a compatible memory DC using the API function CreateCompatibleDC().
3) Use API function CreateDIBSection() to create a DIB of the appropriate size.
4) Select this DIB into the memory DC created in step 2.
5) Use BitBlt() to copy the DD surface from the DC in (1) to the memory DC.

The DIBSection now contains the DirectDraw surface as a DIB, and you can do what you like with it.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2554465
"HOWTO: Capture and Print the Screen, a Form, or any Window"

http://support.microsoft.com/support/kb/articles/Q161/2/99.ASP
0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2554515
Erick37: Are you sure that method will work with a DirectDraw surface...particularly if it has no window associated with it?

Kayan: I should clarify my earlier answer by saying the GetDC() call in step 1 is the GetDC() method of the DirectDrawSurface interface, not the normal Windows GetDC() call.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Kayan
ID: 2554844
pjknibbs:Now I searching a way to get it work in vb with a call to gdi32.  And I need a call to CreateFileMaping because the hSection of CreateDIBSection need to be notnull if a want to be able to use the handle to the bitmap.

Erick37:No there is no window associated with it, it's a memory surface.

0
 

Author Comment

by:Kayan
ID: 2554859
pjknibbs:Now I searching a way to get it work in vb with a call to gdi32.  And I need a call to CreateFileMaping because the hSection of CreateDIBSection need to be notnull if a want to be able to use the handle to the bitmap.

Erick37:No there is no window associated with it, it's a memory surface.

0
 
LVL 12

Expert Comment

by:pjknibbs
ID: 2554949
Yes, I hadn't thought of that. You can do it without using the DIB section, but it's a bit more complicated. Basically, instead of CreateDIBSection() you use CreateCompatibleBitmap(); after you've done the step 5 blit you have to call GetDIBits() to retrieve the bitmap as a DIB.

I'm not sure what you mean about the call to GDI32, however.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2555259
In the MS article I pointed to, the window handle is only used in getting the DC of the target for subsequent bitblting to a memory DC.  If GetDC() works, then the article may provide some hints as to capturing the image.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question