LazyFix tool

LazyFix Tool is a tool that fixes the so-called "lazily-made masks" i. e. the mask is the same as the sprite. Lazily-made masks give issues to PGE, since the algorithm used by it doesn't render properly this kind of mask.

Alpha-channel masks
A mask is an Alpha-channel coding image. Each Pixel of the mask defining the level of opacity of the same pixel on the source image:

Each Pixel of a mask - is a value of opacity for each pixel of the source image:

How it works
Because the lazily-made image is a copy of source image, we must compare all pixels between image and mask.

Before new algorithm was implemented in 2.0 version, old algorithm was: If pixels are equal - fill pixel on the mask by black color.

New algorithm is:
 * Create empty image ' Target ' with a same size which original image has and fill with gray Rgb(128,128,128) color.
 * Fetch each pixel of ' ForegroundImage ' and use same pixel indexes on the ' Mask ' and ' Target ' images and apply per-pixel operatios:
 * Apply bitwise AND between R, G and B pixel values of ' Mask ' and ' Target ' and write into target.
 * Calculate alpha-channel value with a formula:
 * Set alpha-channel value for this pixel equal to ' newAlpha '
 * Apply bitwise OR between R, G and B pixel values of ' ForegroundImage ' and ' Target ' and write them into target without modification of alpha-channel value.
 * Calculate new alpha-channel value with formula:
 * If ' newAlpha ' will have value more than 255 - set to 255.
 * Copy all pixels of ' newAlpha ' value.

Those operations was made the right mask from broken.

How to use
LazyFix tool - is a console tool, you need open the terminal or command line and change directory to the LazyFix tool.

This utility fixes all SMBX64 graphics (GIF with mask images) in an selected folder and (optionally) all graphics inside the subfolders.

The mask must be placed WITH its image, as the fixing process is based on calculating broken pixels by comparing between the pixels of both images.

For fixing graphics which are in one folder: For fixing graphics of an whole episode, you need use the "-d" switch:

Note: After work of tool will be created the " _backup " directory where will be placed broken images before run fixing. If tool made errors aftrer it's worls, you can always restore your old images from backup directory.

You can run fixing without creation of backup directories, if you will apply "-n" switch, but you will can't fix your old images, and you need draw mask manually:

Usage of the LazyFix tool for single images
Also you can simply drag image files into LazyFix application file like into folder, and it will run fix of those images.

Example for the Microsoft Windows Example for the Linux and Mac OS X

Usage of LazyFix tool with GUI
The Editor have a GUI shell for set properties to the lazyFix tool.

For open them, try the menu item: " Tools -> External tools -> Fix Lazily-made graphics (LazyFix tool) "

And you can configure properties for setup the batch fixing. When you press "Start", will be opened the "Development Console" window, where you will see the fixing process.

Links

 * LazyFix Tool Manual
 * Download latest LazyFix tool