======================
== fabulous.systems ==
======================
Welcome to the world of fabulous.systems

About Improving MS-DOS Screenshots With Calculated Distortion


#retrocomputing #msdos

Introduction

Have you ever noticed that a pixel-perfect screenshot from a virtual machine running MS-DOS in the default VGA text mode looks slightly off? The characters are too wide, and the whole image seems stretched.

At the very least, it doesn’t evoke the same nostalgic feeling as the old CRT days, does it?

But did you know that what you’re seeing is a perfect representation of the actual image, while your monitor from 1995 was deceiving you? Let’s have a closer look.

Using a VGA or VGA-compatible display adapter, MS-DOS draws an image with 80 characters per line and 25 lines of text in total. In this mode, each character is 9 pixels wide and 16 pixels tall.

Knowing the size per character and number of characters per screen, we can calculate the exact image size: (80*9)x(25*16)=720x400.

MS-DOS text mode output, unscaled
MS-DOS text mode output, unscaled

ScanDisk, unscaled
ScanDisk, unscaled

So, even though we know that 720x400 is the correct image size, why does it look so wrong?

Compared to the usual screen resolutions from the time, 720x400 is an odd number. When considering monitors from the mid-90s, we are familiar with resolutions of 640x480, 800x600, and 1024x768, which all have one thing in common: An aspect ratio of 4:3.

4:3? Sounds familiar!

Yes, that was the aspect ratio of monitors from the past. Since you wanted to use the full screen size, you adjusted the settings on your monitor until you got a nice image. Contrary to modern displays, CRTs didn’t have a fixed pixel size - in theory, you could draw a “pixel” that filled an entire line if you told the magnets bending the electron beam to do so.

Yep, that’s it. The pixel-perfect screenshots are correct; your settings were wrong 30 years ago. Sort of.

With this in mind, we can easily recreate an image resembling the original monitors’ visuals. We just have to stretch the image to an aspect ratio of 4:3.

The best resolution for the images rendered in 720x400 is 720x540, which perfectly hits the 4:3 ratio. Since we want to introduce as few artifacts as possible, we only stretch the image in one dimension.

And suddenly, the images look perfectly how we remember them:

MS-DOS text mode output, with aspect-ratio correction applied
MS-DOS text mode output, with aspect-ratio correction applied

ScanDisk, with aspect-ratio correction applied
ScanDisk, with aspect-ratio correction applied

Behind the scenes

To illustrate what happens with the image, I prepared a little demo.

Let’s draw an image at 720x400 with alternating black and white lines, each line being exactly 1 pixel tall. The picture looks incredibly sharp - it is pixel-perfect.

Perfect pixels. Zoom in if the lines are too blurry on your screen.
Perfect pixels. Zoom in if the lines are too blurry on your screen.

Now, let’s stretch the image to 720x540 because we want to fix it.

Exactly the same amount of lines, but with aspect-ratio correction applied. Zoom in if the lines are too blurry on your screen.
Exactly the same amount of lines, but with aspect-ratio correction applied. Zoom in if the lines are too blurry on your screen.

I assume you don’t want to count all the individual lines, but if you did, you’d notice that the number stayed the same. We made the pixels a bit larger, adapting them to our desired screen size. Remember, we have an infinite number of possible sizes for the individual pixels.

So, is it always 720x400?

Unfortunatly not. VGA, the VESA standard, and custom modes used by some manufacturers allow for a wide variety of resolutions and character sizes.

For example, the Windows 98 boot screen, technically using MS-DOS at this boot stage, is rendered at 640x400:

Windows 98 boot screen, unscaled
Windows 98 boot screen, unscaled

In this case, our target resolution is 640x480:

Windows 98 boot screen, scaled
Windows 98 boot screen, scaled

To make matters even worse, other graphic modes, like CGA and EGA, again support a multitude of resolutions. The general rule is to stretch your image to the closest size that matches the magic aspect ratio of 4:3.

Check the width of the rendered image and adjust the height accordingly. You’ll soon get used to the most common modes.

One line of ImageMagick

For image manipulation, my tool of choice is ImageMagick whenever possible. You can easily apply the aspect-ratio correction using the convert command. All you need to know is the exact size of your source image and the target resolution.

To convert the picture of the Windows 98 boot screen, I used the following command:

convert win98boot_640x400.png -resize 640x480\! win98boot_640x480.png

That’s it!

Do you have any comments or suggestions regarding this article? Feel free to join the discussion at our fabulous.community!