CFanatic

Go Back   CFanatic > Advance Programming > Game Development

Join CFanatic Forum Now

Loading a bitmap file topic posted under Game Development which is a part of Advance Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2007, 12:00 AM
Junior Member
 
Join Date: Aug 2007
Location: Australia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
wind_addict is on a distinguished road
| More
Loading a bitmap file

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

Last edited by wind_addict; 11-12-2007 at 03:58 AM.
Reply With Quote
  #2  
Old 11-12-2007, 12:55 AM
shabbir's Avatar
Administrator
 
Join Date: Sep 2006
Posts: 1,163
Thanks: 57
Thanked 63 Times in 44 Posts
shabbir has a spectacular aura aboutshabbir has a spectacular aura about
| More
Re: Loading a bitmap file

Use the LoadImage function and it will help you get the image from the disk.
Reply With Quote
  #3  
Old 11-12-2007, 03:57 AM
Junior Member
 
Join Date: Aug 2007
Location: Australia
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
wind_addict is on a distinguished road
| More
Re: Loading a bitmap file

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.
Reply With Quote
  #4  
Old 11-12-2007, 07:10 AM
shabbir's Avatar
Administrator
 
Join Date: Sep 2006
Posts: 1,163
Thanks: 57
Thanked 63 Times in 44 Posts
shabbir has a spectacular aura aboutshabbir has a spectacular aura about
| More
Re: Loading a bitmap file

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.
Reply With Quote
  #5  
Old 04-18-2011, 10:56 AM
Junior Member
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rayan is on a distinguished road
| More
Re: Loading a bitmap file

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++
Reply With Quote
  #6  
Old 08-03-2011, 12:13 AM
Junior Member
 
Join Date: Aug 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
sanam is on a distinguished road
| More
Re: Loading a bitmap file

install allegro package in dev c++...it will help u alot...
Reply With Quote
  #7  
Old 08-16-2011, 02:29 AM
Junior Member
 
Join Date: Aug 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
charlesth is on a distinguished road
| More
Re: Loading a bitmap file

Quote:
Originally Posted by sanam View Post
install allegro package in dev c++...it will help u alot...
Nice package, I found it helpful. Thanks for Suggestion
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crop from one bitmap into another without drawing on screen Tekri Win32 Programming 2 01-18-2009 02:45 AM
Loading Images Zigioman C++ Programming 2 01-07-2009 04:23 AM
File I/O (Reading from a Random-Access File) VersEtreOuNe C++ Programming 0 02-12-2008 03:39 PM
read file n spot blank char n re write file witout extra blank dev1910 C++ Programming 1 12-17-2007 12:43 AM
Display bitmap in different app's window? ajcrm125 Win32 Programming 0 09-30-2006 06:49 PM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:10 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board