                              !OrdPals
                              ~~~~~~~~
                [Ordered Palettes - Alan Wickham 2002]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Copyright notice -
This program is FREEWARE, it may be freely distributed as long as all files
are included and are not altered. It was made using DrWimp and has been "crunched" to save space. If you should wish to modify or add to it, I can supply you with a "Full" version. [ alan@awickham,freeserve.co.uk ]

- Purpose -
 To produce palettes for use with indexed images (Sprites) in which there is a gradual progression from one tone/level to another as the indexing number increases. A typical example of this is the standard Grey Scale in which zero represents Black, 255 represents White and there are 253 equal gradations of Grey in between. The object of Palettes produced by !OrdPals is to replace this Grey Scale by one in which not only the intensity changes but also the colour. They would, therefore, be mainly used for "Toning" Grey Scale images.

Some of the Palettes produced are of, more or less, constant hue and will produce a toning similar to well known chemical toning processes eg. Sepia or Blue (iron) toning. Others give a result that cannot be produced by chemical means, in that the hue changes as the intensity gets lighter. A typical example is where dark tones are, say, green and light tones are, say, pink, the one "gliding" into the other.

Although each Palette consists of only 256 different colours (hues), they are, of course selected from the 16.7 million RGB colour set. In an ideal world the user would be able to decide what sort of colour glide was desireable on a purely visual basis with no need to refer to numbers. This may well be possible at a future date (using the Colour Picker, for exmple) but to keep the program simple it is currently necessary to input numerical parameters. It is quite possible to use the Colour Picker indirectly to obtain these parameters , but some measure of knowedge of colour reprentation systems will be necessary.

The program provides four methods generating the palettes, although there is no reason to believe that any one is better than the others.

1) Start and End Points (Linear).
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Reference should be made to Figure 1.

In this method the Start and End points for each of the three primary colours (Red, Green, Blue) have to be entered (in the "Entry" Window called "Ordered Palettes - Type 1").

The meanings of these terms are as under:-

Start Point:- For all index numbers below this the output component is zero.
              eg. If the Start Point for Red is 30 then the generated palette
              will have no Red component for index Nos. below 30.

End Point:-   For all index numbers above this the output component is a fixed
              255 (the maximum).
              eg. If the End Point for Red is 200 then the generated palette
              will have its Red component set to 255 for index Nos. above 200.

Between the Start point and the End Point the "mapping" of Grey Scale to the new palette is simply a straight line.
There is no restriction on the values entered using this method (provided they are within the range 0 to 255).

This as a rather simplistic approach but it can produce some quite intresting "gliding" palettes. The Palette produced by the "characteristics" of Figure 1 is included as Palette_1 in the examples [Black--> Green--> Yellow--> White].

In all palettes producad !OrdPals Black stays Black and White stays White.

2) Two Break Points (Linear).
   ~~~~~~~~~~~~~~~~~~~~~~~~~
   Reference should be made to Figure 2.
   
This method gives a bit more scope to set the actual hues as desired by, say, indirect use of the Colour Picker. The system works by defining the Red, Green and Blue components at points corresponding to one quater and three quarters of the Grey Scale (1e. Index Nos. 64 and 192). These six values need to be entered in the "Entry" window called "Ordered Palettes - Type 2".

The mapping of the GreyScale to the new Palette is linear between "zero" (Black) and the First Break Point, between the First Break Point and the Second Break Point and between the Second Break Point and "255" (White).
Although, in general, the value for the Second Break point will be greater than that for the First Break point, this is not necesary. there is no reason why it should not be less, thus producing a "zig-zag" mapping characteristic for one or all colour components.

There is no restriction on the values entered using this method (provided they are within the range 0 to 255).

The Palette produced by the "characteristics" of Figure 2 is included as Palette_2 in the examples [Black--> Reddish Purple--> Bluish Purple--> White].

3) Mid Point Colour (Curved - Quadratic).
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Reference should be made to Figure 3.

The object here is to make the data entry a bit simpler by specifying only the colour components at the mid point of the Grey Scale (Index No. 128). In order to do this we have to assume a fixed type of relationship betwen the Grey Scale and the new Palette. It has to be a relationship that makes the new palette values zero and 255 where the Grey Scale has these values. Also, the colour components generated must not go outside the limits 0 and 255. The simplist function for this is a quadratic and this has been used here [See File 'MATH'] but there is a restriction.in that the Mid Point Value is constrained to the range 64 to 190.
This method tends to produce almost "single hue" palettes where the Mid Point Colour is a fair representation of the overall hue. Where there is a change of hue the Mid Point is a fair representation of mid way between the hues of the dark and light tones.
Note that when all three Mid point Values are set to 127 each characteristic is a straight line and the resulting palette is a Grey Scale. This is the default.

A Palette produced by some of the "characteristics" of Figure 3 
(Mid Point Red = 190, Mid Point Green = 70, Mid Point Blue = 127)
is included as Palette_3 in the examples [Black-->Shades of Purple--> White]


4) Quarter Point Colours (Curved - Exponential).
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Reference should be made to Figure 4.
   
This is similar to No. 3 except that the curvature of the mapping characteristics may become more pronounced so that a range of Mid Point values of 1 to 254 is allowed. This is achieved by using a complex exponential function instead of the simple quadratic. 
As with No. 3, an entry of 127 results in a straight line characteristic for that component and 127 in all three (Default) gives a Grey Scale. 

A Palette produced by some of the "characteristics" of Figure 4 
(Mid Point Red = 1, Mid Point Green = 127, Mid Point Blue = 254)
is included as Palette_4 in the examples.
[Black--> Deep Blue--> Pale Blue-Green--> White]


5) Non Linear Grey Scale.
   ~~~~~~~~~~~~~~~~~~~~~~
All four methods may be used to produce Palettes having non linear Grey Scales. To do this simply set ALL THREE colour components to THE SAME values.

Palette_5 is an example using Method 1) ie.
Start Point Red = Start Point Green = Start Point Blue = 70
End Point Red = End Point Green = End Point Blue = 180

Palette_6 is an example using Method 2) ie.
Break Point 1 Red = Break Point 1 Green = Break Point 1 Blue = 50
Break Point 2 Red = Break Point 2 Green = Break Point 2 Blue = 200

Palette_7 is an example using Method 3) ie.
Mid Point Red = Mid Point Green = Mid point Blue = 70

Palette_8 is an example using Method 4) ie.
Mid Point Red = Mid Point Green = Mid point Blue = 30


   USE.(of OrdPals)
   ~~~~~~~~~~~~~~~~
a) Double Click on Icon to load on to icon Bar in usual manner.
b) Click on Icon Bar Icon - main Window will appear on Left Centre of screen (not moveable).
c) Click on one of the Select buttons for the method required. An Entry Window will appear over the Main Window. (Moveable but best left alone at this stage)
d) Enter desired Values into the Writable Icons.
e) Click on the OK button - A window showing the generated Palette will appear on the right hand side of the screen (Not moveable - the sizes are arranged so that this does not cover the Entry Window).
f) If this is satisfactory, click on the OK button - A standard save window will appear. The Palette file may then be saved in the usual way.

Note:- In order to assess the Palette display properly, the screen should be set to (at least) 32 thousand colours. The The application was devised with a screen size of 1024 x 768 px.   


   USE (of Palettes)
   ~~~~~~~~~~~~~~~~~
!Paint:-        Drag the Palette icon onto a suitable Grey Scale inage. If the
                image is not of the crrect matching type an error Window will
                appear.

!ImageMaster:-  Drag the Palette icon onto a suitable Grey Scale inage. Images
                should be changed to Grey Scale first (Colour --> Grey scale).

!PhotoDesk:-    A bit more complicated. Load image and display. If not Indexed
                convert via 'Channels' Window & 'Change image mode' / indexed'
                / 'Grey'.  Selest 'Colouring effect' - a palette display will
                appear.  Drag the OrdPal Palette onto this - the image will
                then change.

Palette Log.
~~~~~~~~~~~
Inside the !OrdPals Application Directory is a file called Pal_Log. When a Palette File is generated this records the Name of the Palette file and the parameters used to generate it. Items may be copied from this file (or deleted) but do not delete the "Backslash" at the end.

Key to entries in Pal_Log file:-

First line = Full File Path.

Second line:- Method 1  SP RED  SP GEEN  SP BLUE  EP RED  EP GREEN EP BLUE

Second line:- Method 2  BP1 RED  BP1 GEEN  BP1 BLUE  BP2 RED  BP2 GREEN BP2 BLUE

Second line:- Method 3  MP RED  MP GEEN  MP BLUE
        
Second line:- Method 4  MP RED  MP GEEN  MP BLUE

Credits.
~~~~~~~~
This application was made using DrWimp.
    