WSQUASH(C) Version 1.0
The SQUASH Utilities for Windows and DOS
(C) Copyright 1995-1999 Bill Buckels
All Rights Reserved.

Distributed as FreeWare

Introduction
------------

The SQUASH Utilities are Graphics Programs for reducing Windows .BMP
Files in size while preserving details (especially in text screens) by
using a process called "SQUASHING". WSQUASH is the core program of the
SQUASH Utilities for Windows and DOS. The SQUASH Utilities also include
two DOS Command Line Programs... SQUASH32.EXE and SQUASH25.EXE.

WSQUASH is a special purpose Windows Graphics Program for reducing
Windows .BMP files in size. A good use for WSQUASH is reducing
screenshots of Windows programs for use as "thumbnails" in Online Help.

If you reduce a 256 color Windows .BMP file in size using conventional
techniques, you will lose detail when shrinking your image. SQUASHING
(scaling by even factors) increases the quality of the reduced image.
Geometric objects are almost preserved. Text is still almost readable.

WSQUASH uses a color loss method called Color Clipping resulting in a
uniform appearance, and reduces your image by 3:2 each time it is
processed. WSQUASH expects that you are running Windows in 256 color
mode (or better), and that you are squashing 2, 16, or 256 color
bitmaps.

WSQUASH is written in Microsoft C using Standard Windows API Calls. It
comes with open source, and may be used and distributed freely. (See the
Source Code agreement for restrictions.)

The SQUASH32 command line program uses the same algorithm as WSQUASH.
WSQUASH will likely be all most folks will ever need, but the Command
Line Programs are included as an "industrial strength" alternative
solution.

If you work in DOS, SQUASH32 is what you want to use to reduce your
image by 1/3 each time it is processed (3:2). SQUASH25 reduces your
image by 1/2 (25% of the area) each time it is processed.

SQUASH32 loses slightly more colors than SQUASH25, but because the
reduction is exactly HALF WAY between SQUASH25 and the original, more
detail is preserved. Text is more readable, and line objects are
clearer.

SQUASH25 on the other hand makes quite a nice thumbnail "preview" image,
and its colors generally don't degrade at all when reducing a Windows
Screen the first time through. (Although SQUASH32's text is still more
accurate.)

SQUASH25 and SQUASH32 will only accept 256 color .BMP files, but they
can be set-up to run unattended in a production environment so there are
benefits as well as drawbacks to using the DOS versions.

Regardless, no Matter if you chose to work in Windows and use WSQUASH,
or to work in DOS and use SQUASH25 and SQUASH32, if you wish to preserve
detail and if you can live with general purpose limited size reduction,
why not SQUASH?

Installing WSQUASH and the SQUASH Utilities
-------------------------------------------

Install WSQUASH by "UNZIPPING" WSQUASH.ZIP complete with pathnames to
the drive of your choice. If you decide to install WSQUASH to Drive C:,
WSQUASH will be installed into the directory C:\WSQUASH.

To Run WSQUASH, click-on WSQUASH.EXE.

Copyright and Conditions Of Use
-------------------------------

The SQUASH Utities are (C) Copyright Bill Buckels 1995-1999
and distributed as FreeWare with Open Source.

You may use and distribute these programs freely, but I assume no
liability for the results of their use. They must be distributed in
their entirety and include this readme file.

Other than that, you have a royalty-free right to use, modify, reproduce
and distribute these programs and their source code and associated files
in any way you find useful (subject to the source code agreement),
provided that you agree that Bill Buckels has no warranty obligations or
liability resulting from said distribution in any way whatsoever. If you
don't agree, remove the SQUASH Utities and all associated files from
your computer now.

Bill Buckels
589 Oxford Street
Winnipeg, Mb, Cdn R3M 3J2

Email: bbuckels@escape.ca
Website: http://www.escape.ca/~bbuckels

The SQUASH Utities are not a derivative work of any other author and are
the exclusive property of Bill Buckels (the author). All methods are the
product of work and study by the author.

Source Code Agreement
---------------------

Squash is distributed with complete source code. You may not use this
code to develop a competitive product. It is included primarily for your
reference if you are interested.

Sample Files
------------

A small number of sample graphics are included in WSQUASH and these are
included to give you something to test. These were produced by the
Author from content that is believed to be in the public domain.

Example Batch Files (PRODUCE.BAT and PLOOP.BAT) are also included to
demonstrate the use of SQUASH32's Mass Squashing capability using
enhanced batch modes.

Program History and What Makes Squashing So Special?
----------------------------------------------------

The SQUASH Utilities are specially designed to reduce screen grabs from
Windows 256 color mode with a minimal loss of detail. This is
particularly useful if you wish to use thumbnails of Windows program
screens in a Windows help file, or for some similar purpose.

I wrote the SQUASH utilities because one of my friends needed to do
exactly that. The image scaling programs that he found out there are are
very good for scaling pictorial bitmaps, but don't seem to do very well
with bitmapped text.

If you do have this special need, you will probably find nothing better
than the WSQUASH.EXE program that is included in this package. You may
want to tweak (perhaps lighten) the colors in your squashed image later
in a more capable and less specialized image processing program. WSQUASH
is just a really simple utility. But I think it it does what it does
very well and since it is freeware, the price is certainly right.

WSQUASH.EXE
-----------

WSQUASH is an enhanced Windows Version of SQUASH32.EXE, and is the
cornerstone of the SQUASH Utilities. I must admit that I didn't finish
WSQUASH to any brilliant level. I couldn't see much point since it does
what the others don't, and the others are already there to do the rest.

When you use the SQUASH Utilities, including WSQUASH, multiple passes
(tries) may be needed before the utility finds the best approach to use.
This is a little reminiscent of many other products that we have seen in
recent years, including products like MemMaker, and the way Windows
95/98 detects hardware.

Needless to say, this trial and error method may appear to be amateurish
and not as elegant as a single pass method, but it was lots easier for
me to program this way. My "shortcut" has also served as a constant
source for teasing from the friend that I wrote this for... so by now
this is part of the SQUASH program personality.

Technically speaking, the first pass of the "SQUASH" can still run over
the color limit, but by using multiple tries and "Color Clipping" (a
simple and consistent color loss method that uses a ratio), composite
colors appear consistently lossy and of an even tolerance, and a uniform
appearance results.

Why Squash?
-----------

If you need to reduce a 256 color Windows .BMP file in size, you will
typically lose detail when shrinking your image.

The reason for this is that many image scaling programs throw away the
colors that they don't use, make bad decisions about which colors will
stay and which ones will be thrown away, or worst of all, create dot
patterns instead of colors (These "dithers" look pretty poor when trying
to represent single line elements and subtle detail like text).

When you have used 20 or so colors and want to shrink your picture down,
the resulting combination can be that several hundred new colors are
needed to represent the colors that blended together from the shrinking
operation.

So the problem that is usually faced is "How do you make room on a
computer screen for more colors than the screen can hold?" As I said,
many programs don't and some don't even try.

In a typical Windows Environment with only 256 colors there are still
simple ways to achieve a good compromise, by "SQUASHING" instead of
"SCALING". What I mean by "SQUASHING" is "scaling by even factors". The
loss of detail can mostly be overcome by this simple technique.

This increases the likelihood of new colors being consistent, because
after all, since if you start with only a handful of colors as in the
case of an image of a Windows Application's Screen, there are a finite
number of maximum combinations, and many will be close.

The other matter that is solved by even scale factors is that the
quality of geometrical objects like rectangles and line elements is
almost preserved. Circular objects do suffer, but not so badly.
Anomalies like "Aliasing" are still superior and easier on the the eyes
than typical lossy scaling algorithms that throw away pixels.

Simple "SQUASHING" utilities... SQUASH32.EXE vs SQUASH25.EXE
------------------------------------------------------------

SQUASH32 is what you want to use to reduce your image by 1/3 each time
it is processed (3:2).

SQUASH25 reduces your image by 1/2 (25% of the area) each time it is
processed.

SQUASH32 loses slightly more colors than SQUASH25, but because the
reduction is exactly HALF WAY between SQUASH25 and the original, more
detail is preserved. Text is more readable, and line objects are
clearer.

SQUASH25 on the other hand makes quite a nice thumbnail "preview" image,
and its colors generally don't degrade at all when reducing a Windows
Screen the first time through. (Although SQUASH32's colors are still
pretty accurate.)

The source code for SQUASH32 and SQUASH25 is included with these
utilities and so feel free to adapt these to your own purposes. If you
can display a large number of colors you don't need to compromise by
"SQUASHING". Variable scaling will achieve comparable results.

But if you only have 256 colors to work with and need to achieve uniform
representation "SQUASHING" is the best approach.

SQUASH32 Copyright (C) 1995 by Bill Buckels
-------------------------------------------

Usage is : "SQUASH32 [BMP256.IN] [BMP256.OUT] (optional-shift (1-8))"

For Automatic name generation...
Usage is : "SQUASH32 [BMP256.BMP] (optional-shift (1-8))"
Output is: "[BMP256.BMW]"

For Help : "SQUASH32 ?"
Returns  : 0 = Success, 1 = Invalid, 2 - 8 = Failure (suggested shift)

Scale a 256 color bitmap to a 3:2 ratio of its original size using color
averaging and a user defined color clipping ratio.

The Color Scaling Algorithm applies the following convolution to the RGB
gun values in the image to scale the image:

 Multiplier X RGB  - Sum - Divide by 9 = Average Color
 PIXEL                            PIXEL
    _______________                  _______________
 R  | 4  | 2  | 4 |               R  |4+2+2+|2+4+1+|
 A  |____|____|___|               A  |1 /9  |2 /9  |
 S  | 2  | 1  | 2 |     To        S  |______|______|
 T  |____|____|___|               T  |2+1+4+|1+2+2+|
 E  | 4  | 2  | 4 |               E  |2 /9  |4 /9  |
 R  |____|____|___|               R  |______|______|

Typically the color resolution of the result will be greater than the
palette even with the fixed scale reduction. A color loss algorithm is
applied to the RGB gun values after scaling. Color resolution is lost by
2's compliments, by shifting the gun value right then left. This value
is set to 4 by default but is user definable.

SQUASH25 Copyright (C) 1995 by Bill Buckels
-------------------------------------------

Usage is : "SQUASH25 [BMP256.IN] [BMP256.OUT] (optional-shift 1-8))"
For Help : "SQUASH25 ?"

Scale a 256 color bitmap to half its original size using color averaging
and optionally (if requested) a user defined color clipping algorithm.
The Color Scaling Algorithm applies the following average sum to the RGB
gun values in the image to scale the image:

 Sum - Divide by 4 = Average Color
 R  PIXEL
 A  -------|-------
 S  | RGB  +  RGB |
 T  ---+---|---+---     /4  = RGB
 E  | RGB  +  RGB |
 R  -------|-------

Typically the color resolution of the result will be greater than the
palette even with the fixed scale reduction. A color loss algorithm can
be applied to the RGB gun values after scaling. Color resolution is lost
by 2's compliments, by shifting the gun value right then left. This
value is set to 0 by default but is user definable.

End of Document
