Solved

Saving a DDSurface to .bmp file

Posted on 2000-02-24
7
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Accepted Solution

by:
pjknibbs earned 75 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 18 hours left to enroll

623 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