Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading & Loading a bitmap in DOS

Posted on 1998-06-16
5
Medium Priority
?
421 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…
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.
Suggested Courses

618 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