Name

map_color_replace - Map and rearrange pixels and pallette entries in map image

Synopsis

map_color_replace <command> <options> <bmp_file>

Description

  1. Replace pixels with one value by pixels of the other value (making both be of the same color and effectively reducing number of colors in image).
  2. Replace RGB value of a pallette entry with other value (effectively changing color of all pixels corresponding to the pallette entry).
  3. Rearrange pallette entries without changing color of the pixels (effectively leaving the same color image of the map but optimizing its grayscale image).

Command:

-c
map pixels' colors (pixel values changes, pallette intact), mode 1 above
-p
map pallette (only pallette changes), mode 2 above
-g
map grayscale values (pixel values changes, pallette reordered), mode 3 above

Options:

--mapfile=<file>
mapping file to use
--map=auto
use automatic mapping for (-g)
--pallette=gray
use grayscale pallette (with -g (for preview) and -p)
--pallette=reverse
swap pallette order (with -g (for preview)). (Required for preview on desktop where less pixel value means darker color, whereas default is grayscale handheld color mode where less pixel value is lighter color).
--outfile=<file>
name of resulting image file

Format of mapping file:

RRGGBB=>RRGGBB
Where RR, GG, BB - hexadecimal representation of corresponding color. Several mapping can be specified in single file. Lines starting with '#' are comments. For -c mode, both source and target color must exist in image. For -p mode, source color must exist in image.

Examples

Drop one (tint of) color in favor of another

World.map:

05819f=>00809e

map_color_replace -c --mapfile=World.map World-in.bmp --outfile=World-out.bmp

After this command, image will no longer contain pixels whose color is 05819f. (There still will be pallette entry for that color though. To reclaim it, image should be converted (by third-party tool, e.g. graphics editor) to RGB mode and then back to palletized mode).

Replace one color with another

sample.map:

00FF00=>00c000

map_color_replace -p --mapfile=Sample.map sample-in.bmp --outfile=sample-out.bmp

After this command, bright green color will be turned into dimmer green.

Optimize image for grayscale handheld device

map_color_replace -g --map=auto World-in.bmp --outfile=World.bmp

After this command, color cut of image will remain unchanged, but grayscale cut will become optimized (naturally looking) for grayscale devices.

Preview grayscale cut of an image before optimization

map_color_replace -p --pallette=gray --pallette=reverse World-in.bmp --outfile=World-bad.bmp

Preview grayscale cut of an image after optimization

map_color_replace -g --map=auto --pallette=gray --pallette=reverse World-in.bmp --outfile=World-preview.bmp