copy from a file

Started by
3 comments, last by jagguy 19 years, 2 months ago
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
Advertisement
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.
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 ?????????????????????

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]
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.

This topic is closed to new replies.

Advertisement