Thread: Compile files into execs

  1. #1
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937

    Compile files into execs

    How would I compile a picture file into a program so that I can access it in the program, but it is part of the program?
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    Umm...well the only thing I could think of would be to manually recreate it pixel by pixel in your code...if you study the file format for the picture you want to do this with, you may be able to read in all of the numbers in there, pour them out into a file, and pick over it translating it into a form that you can manually code into your program (put all of the points and color values into an array) and write an algorithm to paint it out...


    but why on Earth would you want to do this?

    Hey, you're from florida too? what part?

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    You can create bitmap resources in your resource file, these are then "compiled" into your program. There are some restrictions on the type of bitmaps you can use, can't remember off the top of my head, but I think you are limited to 256 colours for example. Look this up in the help.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    202
    adrianxw- shouldn't that depend on his compiler?

  5. #5
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> shouldn't that depend on his compiler?

    Probably, (ISTR there is a limit in VC for example), - hence...

    >>> Look this up in the help.

    ...if there is a limit, he may find it there, (although again, ISTR finding this out by experience rather than anything useful in the documentation).
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #6
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey,

    I think if your bmp is more than 256 colours then you can just import it rather that create it, this is what i did in msvc 6. Then if you try to view it in the resource editor it just says that it has exceeded 256 colours and cannot be opened but it will be compiled into the prog fine. So you can just import your bmp into your resource file and access it from there.


    Hope thats of some help,
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  7. #7
    Registered User ExDigit's Avatar
    Join Date
    Jan 2002
    Posts
    31

    Using resources..

    If you're going to use a resource file to include the bitmap with your program, read the following:

    http://www.winprog.org/tutorial/bitmaps.html

    Good luck.

  8. #8
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    Ya, (TNT), I created an empty WIN32 program, so I don't have a resource file (.h or .cpp). How do I incorporate a file? I need to give it an ID.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  9. #9
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey codemonkey,

    Heres how to import your bmp into your resource to compile, and build into the exe.

    In Msvc6 do:

    1. File/New - Files Tab - Resource script, enter name and stuff.

    2. Insert/Resource, you should get up a dialog.

    3. Click Import, select all files and find your bmp and import it

    Thats it , you can now assign an ID to it, it will be in bitmaps catogery in your resource file. Then just include resource.h in your app and compile and its built in.

    Hope thats what you wanted.
    TNT
    TNT
    You Can Stop Me, But You Cant Stop Us All

  10. #10
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    *A chorus sings as a lightbulb is turned on*


    Thanks.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-c++ + own .h files = unable to compile
    By wixz64 in forum C Programming
    Replies: 5
    Last Post: 05-29-2008, 03:35 PM
  2. accessing all files in a folder.
    By pastitprogram in forum C++ Programming
    Replies: 15
    Last Post: 04-30-2008, 10:56 AM
  3. How to compile .c files with Visual C# Express 2005
    By daYz in forum Windows Programming
    Replies: 2
    Last Post: 02-22-2008, 10:37 AM
  4. 3 Files of OO Language
    By rayrayj52 in forum C++ Programming
    Replies: 4
    Last Post: 11-03-2004, 02:08 PM
  5. reinserting htm files into chm help files
    By verb in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2002, 09:35 AM