A Novel Use For Bitmap Files


As you know, bitmap (.BMP) files are generally used for storing image data. But did you know that bitmap files can be used for storing any kind of data?

To illustrate, consider the following bitmap image (named "DATA.BMP"):

Not much to look at, is it? -- Just a lot of meaningless gray streaks, rectangles, and random dots. But then this image was not created with the intention of being looked at by eyes; it was created to be "looked at" by a computer program. It is a data image.

To see what's really inside the above DATA.BMP image, first copy it to the root directory of your "C:" drive (by right-clicking on the image and selecting "Save Picture As..."). Then run this Pro-SiMPLE program.

As you can see, data images are a cool way of distributing data via the Internet! -- The user simply right-clicks the image, saves it to his computer, and then runs the appropriate program to access the data.

How Can I Create My Own Data Image Files?

If you are familiar with the structure and format of bitmap files, the most direct way is to simply write a program to generate the 24-bits/pixel bitmap file (i.e., a 54-bit bitmap header followed by all of your data). But this can be a bit tricky for a novice (and there are several pitfalls that you need to be wary of).

An easier (but somewhat more awkward) approach is to simply use the MSPAINT program to create an "empty" 24-bits/pixel bitmap image (i.e., all white pixels), and then replace the pixels with your own data. Specifically:

  1. First, store all your data into a temporary file named "MYDATA" in the root directory of your "C:" drive.
  2. Next, use the MSPAINT program to create an "empty" 24-bits/pixel bitmap image that is large enough to hold all your data. (The image's height times its width times three must be greater than or equal to the number of bytes of data that you wish to store.) Save this image as "SHELL.BMP" in the root directory of your "C:" drive.
  3. Finally, run this short Pro-SiMPLE program to merge the contents of "MYDATA" with the header information in "SHELL.BMP". The result will be the data image "DATA.BMP" in the root directory of your "C:" drive.

When writing the program that retrieves the data from the image, remember to skip past the bitmap header (the first 54 bytes):

Pro-SiMPLE
Int data, eof
open a ("read C:\\DATA.BMP")
Do k = 1, 54
   read binary a (data, eof)   //ignore the data
Loop
        . . .
 (the rest of your program)
        . . .



  [ Webmaster | FAQ's | Home Page | Contact Us ]