Changing the "Size" of an Image


Let's suppose you want to look at a bitmap image of a circle on your display screen. You know that the diameter of the circle is exactly 100 pixels.

Question: "How big (in inches, or whatever) will the circle be?"
The answer, of course, will depend on the size of your display. If you use a 25 inch monitor, the circle will be bigger that it would appear on a 17 inch monitor. (Duh . . . It just stands to reason, right? After all, pixels are nothing more than binary numbers. And numbers don't have a physical "size" to them.)

Now, let's suppose you want to make a hard-copy printout of that same bitmap image. So you load the image into the Windows PAINT program and request a printout.

Once again, we ask the question: "How big will the circle be?" And, just as before, the answer should  be: "It depends on the physical size of the paper that you're using." (Duh . . . It just stands to reason, right?)

But wrong! . . . It doesn't work that way!!!

For some silly reason, all bitmap images have a physical size "hard wired" into them! (It's in locations 38-45 of their header records.)

Of course you can always scale  the image to some other  size (if you are willing to accept the subsequent loss of resolution). But you are not given direct control over the actual number of pixels per meter for the original  image.

Fortunately, there is a SiMPLE solution to this problem. All you have to do is write a relatively short program to change the values that are stored in locations 38-45 of the image's header record.

For example, the following example program will read the "OLD.BMP" image file, change the "horizontal resolution in pixels per meter" to 4096, change the "vertical resolution in pixels per meter" to 8192, and then save the result as an image file named "NEW.BMP":

Example Program Listing

Of course, setting the horizontal resolution and the vertical resolution to different values will produce a distorted (flattened) image when printed out. But we did it here merely for purposes of illustration.



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