Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reading & Loading a bitmap in DOS

Posted on 1998-06-16
5
Medium Priority
?
425 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 450 total points
ID: 1166027
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
ID: 1166028
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
ID: 1166029
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
ID: 1166030
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
ID: 1166031
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 Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Suggested Courses

810 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