Put the picture through the converter, to have the 160x240 pixel.
Check the available colours per line.
Check the available Atari colours.
Drop the colours down to a countable use, for the available colour changes and usable colours.... per line
Put the "original" picture again through the converter with the aimed "fitting" colours and use dithering for that.
This is exactly how /init=smart and /init=less work.
Preprocess (no matter what type of /init is chosen)
0. Input picture is converted to 160*height pixels -> output.png-src.png
0.1. Picture palette is converted to full Atari palette and dithering is applied if chosen -> output.png-dst.png
Initialization for /init=smart and /init=less:
In each line
1. /init=smart reduces the number of colors to the closest 12 Atari colours (8 with /init=less).
2. Colors are sorted by the number of pixels in the line (descending order)
3. In sort order colors are assigned to the playfield colors, then to sprite colors, then (if we have free cycles in the line) again to the playfield colors
4. Sprite positions are set to match the position of sprite color pixels
This works well for simple pictures, but gives worse results than /init=random for complex pictures, because the algorithm stuck in a local optimum.
Edited by ilmenit, Mon Jun 4, 2012 5:04 AM.