Solved

Reading & Loading a bitmap in DOS

Posted on 1998-06-16
5
414 Views
Last Modified: 2013-11-19
How do I read and load a bitmap in DOS (Borland C++ 4.5 or 5.0).
I have set the Video Mode to 320x200x256.
0
Comment
Question by:dennis061698
  • 4
5 Comments
 
LVL 2

Accepted Solution

by:
kinkajou earned 150 total points
Comment Utility
I will try to summarize the process but entire chapters are written about what you are asking. If you want a reference book, try "Tricks of the Game Programming Gurus" from SAMS publishing. Chapter 5 has a detailed example of exactly what you are asking about. Note: this book is only useful for DOS programming. Answer coming...
0
 
LVL 2

Expert Comment

by:kinkajou
Comment Utility
Dennis,

To read in the image, you may need to uncompress the bitmap. Different bitmaps have different formats and methods of compression. Decompression information/algorithms for the most common formats (GIF, TIFF, BMP, PCX, PPM, etc) can be found on the web and you may even be able to find source code for the decompression. Simply, you would want to extract the palette from the bitmap header to set your video palette, examine the format header for the method of decompression and decompress the image setting each byte value from the uncompressed image in a char array that is the size of the product of the width of bitmap and the height of bitmap.

Once the image has been decompressed, you want to display it at the coordinate of your choice. The address of the video buffer is 0xA0000000L. You will need to offset from that address to acount for the coordinate position you want the bitmap to be displayed. Once you have calculated the position, you display each horizontal line of the bitmap, skip the space from the end of the bitmap to the right edge of the screen and the space from the left edge of the screen to the start of the bitmap, for all of the horizontal lines of the bit map. To diaplay a horizontal bitmap line, you must write each pixel for the line. To write a pixel you change the value of video memory to the value of your corresponding pixel in your char array.

#define SCREEN_WIDTH 320
#define BITMAP_WIDTH  to be filled in with bit map height
#define BITMAP_HEIGHT to be infilled in with bit map width
.
char bit_map_array[BITMAP_WIDTH*BITMAP_HEIGHT];
unsigned char far *video_buffer = 0xA00000000L;
unsigned char screen_offset,bitmap_offset;
.
screen_offset =  SCREEN_WIDTH*y_position_of_bitmap+x_position_of_bitmap;
bitmap_offset = BITMAP_WIDTH;
.

for (y = 0; y < bitmap_height; y++)
{
   for (x = 0; x < bitmap_width; x++)
   {
      video_buffer[screen_offset+x] = bit_map_array[bitmap_offset+x];
   }
   screen_offset += SCREEN_WIDTH;
   bitmap_offset += BITMAP_WIDTH;
}

I hope this isn't too confusing and helps you. Again, there are books that will discuss the palette setting and the bitmap displaying along with gaming concepts and graphics concepts. The "tricks of the game programming gurus" is an good guide.

Good Luck!
Kinkajou
0
 
LVL 2

Expert Comment

by:kinkajou
Comment Utility
One site that may have some helpful information for you as far as resources go.

http://hercule.csci.unt.edu/larc/
0
 

Author Comment

by:dennis061698
Comment Utility
Thanks.
Your info helped alot, but there are still a couple of things that are confusing...
Couldn't you send me the program example from the book you mentioned concerning this?
0
 
LVL 2

Expert Comment

by:kinkajou
Comment Utility
I wish I could send the book's example but it is copyrighted and I read the copyright and it does not allow me to distribute the example. You could go to the local bookstore and copy it out of the book.You can check with your library for DOS graphics books.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maze travler 6 47
D3, dragging and rotating. 7 93
RGB code colors 8 79
is twain_32.dll cmpatible with windows 10 ? 10 94
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Learn how to use the remote presentation tool in Prezi to allow you to harness the power of this cloud based presentation platform. You can show your presentation with a remote audience using this free tool.
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now