?
Solved

Reading & Loading a bitmap in DOS

Posted on 1998-06-16
5
Medium Priority
?
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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