Thread: BMP as part of executable

  1. #1
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001

    BMP as part of executable

    I need to know how to put a .bmp into my executable so that the program doesn't have to go look for the file, it will be within it's own code this way. I have the file included in the project, i'm currently building as debug...are there any further steps i need to take? I reference the picture right now by it's absolute path on the hard disk, I assume if it gets included into the program all i have to do is type the name of the pic, not any particular path. Any help would be appreciated.


    I'm using MS Visual C++ 6
    PHP and XML
    Let's talk about SAX

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    To include the data of the bitmap within the executable, include it as a rexource using the resource editor, it will then not be necessary to distribute the .bmp with the application.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    yeah i got that far, but how then do i use it from there? if it was somewhere else i would use the exact location "c:\whatever..."
    when it's included, I need to know how to use it then, it gets stored as IDB_BITMAP1 by defualt, i try to use IDB_BITMAP1 as the variable when i try to get the image, but it's undeclared, so I try to include the resource script (generated by MFC) and it has errors in it (is this a known bug in VC++?) so basically i'm stuck for now.
    PHP and XML
    Let's talk about SAX

  4. #4
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    Look into the LoadImage() and LoadBitmap() functions.
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  5. #5
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    when its in your resource, include resource.h and use the macro MAKEINTRESOURCE() instead of the path

    ie:
    LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP));
    "There are three kinds of people in the world...
    Those that can count and those that can't."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2009, 12:57 AM
  2. how to make an executable file by ourselves?
    By Masterx in forum A Brief History of Cprogramming.com
    Replies: 22
    Last Post: 03-15-2009, 04:35 AM
  3. saving bmp image files
    By aniramg69 in forum C Programming
    Replies: 10
    Last Post: 12-30-2008, 10:08 AM
  4. Suspicious Pointer Conversion
    By mr_spanky202 in forum C Programming
    Replies: 35
    Last Post: 04-11-2003, 12:35 PM