1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Loading a bitmap file

Discussion in 'C++' started by wind_addict, Nov 12, 2007.

  1. wind_addict

    wind_addict New Member

    Joined:
    Aug 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Systems Admin
    Location:
    Australia
    Hello everyone I am a noob in c++ and am writing a little game. I am wanting to read a bitmap file into my program into a memory DC and assign a HBITMAP handle to it so I can then BitBlt it as needed. The bitmap is an image of the tiles I need to use. I know how to load the bitmap if I make it a resource in the executable file, however as there will be a number of images I need, I want to be able to read the bitmaps as needed from the actual .bmp file. I have tried quite a few tutorials found through google but with no luck. I only need to read in 24bit bitmaps, so don't need any code for palettes.

    Could someone shed some light please? I am reading the file header and info headers OK, and the data. I think I am going wrong from there because when I try and do a CreateDIBitmap from the data, it does not show anything except a black box.

    thanks
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    Use the LoadImage function and it will help you get the image from the disk.
     
  3. wind_addict

    wind_addict New Member

    Joined:
    Aug 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Systems Admin
    Location:
    Australia
    Hi Shabir I want to pack all my image files into one big .dat file, therefore need to load the bitmap using raw methods. I am using LoadImage in the meantime, by would prefer to do it the other way.
     
  4. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    Thats pretty simple. I would share one of my such experience where I have done something similar. What I did is used a Guid to distinguish the pack and unpack the data file which was an executable file.

    I wrote one executable (which I could not share) which reads the content of the file in the folder and puts them into the executable seperated by a special string .

    Now the final executable actually reads through the same string and then puts the file into the temp folder which are used later. I think you can also try something similar where you pack everything into the dat file and then extract and keep them at the temp location and then use them to display it and the when done delete them. I hope it helps.
     
  5. rayan

    rayan New Member

    Joined:
    Apr 18, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    i need a help in:
    1. You should setup and display the board by filling it with the corresponding values. Your values should NOT be visible to the user but rather you should display the number of each square e.g. the first square of the first row has the number 1 and the last one has the number 8; the first square of the second row has the number 9 and the last one has the number 16, etc.

    2. The user should then start guessing the locations of each pair of identical values by choosing two squares (i.e. by entering their numbers). You are free to choose to ask the user to choose each square alone or both at the same time. Whichever method you choose make sure the users knows exactly what you’re expecting.

    3. Once two locations are chosen you should then display the board again and uncover them. If the user made a right guess then both squares should remain uncovered throughout the rest of the game. Otherwise, you should cover them again and re-display their numbers.

    4. The user is not allowed to choose a non-existing square nor an already uncovered one.

    5. The game ends when the user guesses all pairs of identical values or if he/she chooses to stop by entering some sentinel value of your choosing.

    6. Your program should display at each round the status of the board and the total number of guesses (whether right or wrong).
    using c++
     
  6. imported_sanam

    imported_sanam New Member

    Joined:
    Aug 3, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    install allegro package in dev c++...it will help u alot...:)
     
  7. charlesth

    charlesth New Member

    Joined:
    Aug 6, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    Nice package, I found it helpful. Thanks for Suggestion
     

Share This Page