Thread: difficult bitmap question

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    60

    difficult bitmap question

    So I wrote a class for sprites, and a different one that contains useful functions to initialize a DirectDraw Primary Surface

    class DDIniClass{

    // Here I've got this function:
    LPDIRECTDRAWSURFACE7 MakeSurfaceFromBmpFile(LPSTR
    NameOfBmpFile);

    // The function above returns a pointer to a surface created to
    // 'store' the bitmap specified by f.e. "c:\\\\dummy.bmp"
    }

    // Now inside my Sprite Class I've got a Create Function:

    class EasySprite{

    BOOL Create(LPDIRECTDRAWSURFACE7 lpDDSurf);

    };

    // As you can see a call like

    DDIniClass Screen;
    EasySprite Picture; // Guess these two are global

    Picture.Create(Screen.MakeSurfaceFromBmpFile(("c:\ \\\dummy.bmp"));

    // The code above works fine, and I wrote some easy animations

    /* ------NOW THIS IS MY QUESTION ----------*/

    // Whenever I call EasySprite.Create I have to know the exact path of my bitmap file (f.e. "c:\\\\dummy.bmp");
    // I must never copy the bitmap file to a different folder, or the program won't work anymore! So the successful execution of the program depends on the existence of a bitmap file located exactly in a folder where the program 'thinks' it is due to LPSTR.
    // When my friend would like an animation I must tell him to create a folder for the bitmap that has exactly the same path as it had on my c:\\.
    // Isn't this complicated? Is there a possibility to link the bitmap to the program so that it is 'part of the executable file', so the program will work once it is built, no matter if or where the bitmap file exists?

    // -------------

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Change C:\\MyProgram\\MyBitmap.bmp to MyBitmap.bmp. It will find the bitmap ifit lies in the same folder as the program. Ifyou place it in a subfolder, use MySubFolder\\MyBitmap.bmp.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exam Question - Possible Mistake?
    By Richie T in forum C++ Programming
    Replies: 15
    Last Post: 05-08-2006, 03:44 PM
  2. I need help to compile this code...
    By wise_ron in forum C Programming
    Replies: 17
    Last Post: 05-07-2006, 12:22 PM
  3. LoadBitmap with variable bitmap name
    By Isometric in forum Windows Programming
    Replies: 2
    Last Post: 11-16-2003, 10:36 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM