Sign in to follow this  
jagguy

copy from a file

Recommended Posts

jagguy    100
i am using ddutil.h for a directX7 program that simply reads from a file and displays a sprite(just a short program) the problem is CreateSurfaceFromBitmap function in ddutil.cpp. I want to read in a bitmap from a file and not a resource...I dont understand the resource anyway. I have all the parameters except passing the string of the file name is giving me errors with this. Can you use a file name with this funtion ( eg load the file name into char*) or do you need to pass a resource name ...which I dont get. It works with a resource name by I dont understand it

Share this post


Link to post
Share on other sites
By reading the source file, I found this comment:

//Name: CDisplay::CreateSurfaceFromBitmap()
//Desc: Create a DirectDrawSurface from a bitmap resource or bitmap file.
// Use MAKEINTRESOURCE() to pass a constant into strBMP.


So, yes, it can load files. What errors are you getting? And what does the code look like? You are probably just doing something wrong.

Share this post


Link to post
Share on other sites
jagguy    100
Quote:
Original post by lack o comments
By reading the source file, I found this comment:

//Name: CDisplay::CreateSurfaceFromBitmap()
//Desc: Create a DirectDrawSurface from a bitmap resource or bitmap file.
// Use MAKEINTRESOURCE() to pass a constant into strBMP.


So, yes, it can load files. What errors are you getting? And what does the code look like? You are probably just doing something wrong.


I am simply passing the file name as a string to the 2nd variable
strcpy(sfile,"c:\...")

How do I use this for a simple filename to pass on, do I ned to convert a filename .bmp into a resource...?
.......Use MAKEINTRESOURCE() to pass a constant into ?????????????????????

Share this post


Link to post
Share on other sites
Quote:

strcpy(sfile,"c:\...")

Well, from what you show there, if that is the way you are spelling the string, it is incorrect. The'\' is the escape-sequence character in C++. So, you need to use an escape-sequence to allow the language to process it correctly. Just type the '\' twice, like this:

strcpy(sfile,"c:\\somefile.bmp");


I am guessing your compiler gave you warnings about unknown escape sequences. Well, if so, that is why.

As far as MAKEINTRESOURCE, that is for converting a defined constant number to a string stored in an .rc file. Resources are just data embedded directly into the .exe, and the Windows API comes with many functions for accessing that data. However, it's more than I could explain here. You'll probably just have to look it up somewhere.

[Edited by - lack o comments on February 14, 2005 6:59:23 AM]

Share this post


Link to post
Share on other sites
jagguy    100
Quote:
Original post by lack o comments
Quote:

strcpy(sfile,"c:\...")

Well, from what you show there, if that is the way you are spelling the string, it is incorrect. The'\' is the escape-sequence character in C++. So, you need to use an escape-sequence to allow the language to process it correctly. Just type the '\' twice, like this:

strcpy(sfile,"c:\\somefile.bmp");


I am guessing your compiler gave you warnings about unknown escape sequences. Well, if so, that is why.

As far as MAKEINTRESOURCE, that is for converting a defined constant number to a string stored in an .rc file. Resources are just data embedded directly into the .exe, and the Windows API comes with many functions for accessing that data. However, it's more than I could explain here. You'll probably just have to look it up somewhere.


thanks
i used a .rc file after all. I found out how and its not really that big deal.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this