Prior to this fix, the following particular conditions caused
an incorrect conversion of an opaque color to a transparent color
during RGBA->Indexed conversion:
- RGBA image with black color (#000000 a=255) painted on the canvas
- The black color is absent from the palette.
- The mask color is present in the palette
- Converts the sprite to indexed color mode using
Sprite > Color Mode > More Options
- Select Advanced Options, select a Color Best Fit Criteria other than
Default (for example CIELAB) and press OK
- The original black color becomes the mask color.
Now we lazily initialize the description of each backup on each
session. This means that only when we have to display the item on the
screen (onPaint) we'll ask for the description/doc
info (width/height/color mode, etc.). We've also removed the check of
all magic numbers of every single object in the backup when we only
need the doc description.
It's now possible to get/set the selected foreground/background tile
index. Example of use:
app.fgTile = 1 -- the primary tile is '1'
print(app.fgTile) -- this will show '1'
app.fgTile = 0 -- the primery tile is 'no tile'
print(app.fgTile) -- this will show '0'
app.bgTile = 2 -- the secondary tile is '2'
Introduced Key::isListed() and Command::isListed() to customize when a
command should be displayed in the list of shortcuts.
Removed commands:
'Launch'
'OpenBrowser'
And removed unnecessary commands:
'Change Color Mode: Indexed'
'Contract Selection'
'Export Sprite Sheet'
'Flip Canvas Horizontally'
'Frame Properties'
'Load Palette'
'Open Sprite'
'Playback Speed 1x'
'Run Script'
'Save Palette'
'Select Used Colors'
'Set Palette Entry Size'
'Tileset Mode: Auto'
This regression came from 09bb5cc3d3 as
now we don't Sprite::setTransparentColor() on each undo/redo and only
when needed. This brought a new kind of error where the mask color for
images was set to -1 after convert_pixel_format().
This also fixes a conversion from Indexed -> RGB where the transparent
color was not set back to 0. And the transparent color is always set
when we are in indexed mode to avoid any assert in debug mode.
When we are in Indexed mode we can have a specific index as the
transparent color, if we convert the sprite to RGB, that transparent
color is lost, so we have to save it (in a cmd::SetTransparentColor)
to restore it correctly when we undo the ChangePixelFormatCommand.
Original issue title: When using a background layer, switching to
Indexed Color Mode fills all layer bounding rectangles with
Color 0.
Conditions to reproduce the original issue:
- Opaque RGBA sprite, i.e. the bottom layer is 'Background'.
- There is a second layer with an ellipse (for example).
- There is a mask color #000000 alpha=0 is in the palette.
- The mask color index is greater and not equal than 0.
- Go to Sprite > Color Mode > Indexed.
Result: the transparent color of the second layer will change to
index color = 0 (usually black).
Also added test for RGBA->INDEXED conversion
Before this fix, the lua command:
app.command.ExportSpriteSheet
could not process a layer within a group when the layer name
was expressed using the layer hierarchy path, for example:
layer = "Group1/Layer1"
We can select the default color or tile from preferences depending if
we're going to paint pixels or tiles
Fixes a confusing logic from 4a91d150af
where the bg color was obtained from preferences only when the fg
color type (rgb/gray/index/hsv/tile/etc.) was equal to the bg color
type from the preferences (rgb/gray/index/hsv/tile/etc.).
To reproduce the error before this fix on RGBA/Grayscale Color Mode:
- New 100x100 RGBA/Grayscale opaque sprite (white background).
- Draw something with some gray color in the palette.
- Keep the selected gray color as primary color.
- Configure as secondary color the mask color (#000000 alpha=0).
- Pick 'eraser' tool and erase over the gray color with right click.
- Result: The sprite doesn't look more opaque, which is wrong. Also,
if we export this sprite, the transparent parts will turn black.
A similar problem occurs in Indexed Color Mode, but getting a
transparent color in a Background sprite is inevitable if the color of
a palette entry is transparent or semi-transparent, since the index
must be set as is. This could be fixed in the future at the
render stage, however, this could lead to other perceived
inconsistencies. For now it'll be left as is.
Original issue description:
Downloaded PNG in RGB mode fails to support transparency: erase
uses secondary color and export PNG replaces transparent color
with black
Added tests for 'eraser' in 'Replace Color Mode'
To make the eraser work in 'Replace Color Mode' within the tests,
was implemented the possibility of using the right button in
the creation of the point vector.
During testing with UI available it was observed that the 'bg' color
was copied from the 'fg'. Changed this to be compatible with the way
the default value of 'fg' is assigned when it is not specified.
This last modification resulted in errors during 'tilemap.lua' due to
incompatibility of the type of 'bg' color. This was corrected
considering the color type of 'fg' color.
Furthermore, it was found that the command 'app.range.tiles = { 1 }'
did not finish assigning the tile picks to the activeSite,
then 'assert(1, #app.range.tiles)' was failing. This was fixed too.
Added other color comparison criterias (fit criteria) during
color mode conversion RGBA to Indexed or Grayscale to Indexed.
The 'fit criteria' will help us to recolor an RGB image with
a limited color palette taking into account different color
perception criteria (color spaces: RGB, linearized RGB,
CIE XYZ, CIE LAB).
Before this fix, a multi-layer mask movement/scaling (with mixed layer
types: normal layer and tilemap layers with different grids) caused
loss of drawing areas.
The heart of this solution is to correctly align the 'selection mask'
and 'transform data' according to the layer's grid, and also, forcing
'site' TilemapMode/TilesetMode before each
reproduceAllTransformationsWithInnerCmds() iteration.
During the life of a PixelMovement object there is a tilemap mode lock.
Additionally arrow keys now work to move a selected area in
TilemapMode::Tiles.
This was originated for #1279 (CLI-only Aseprite) which can be
achieved with LAF_BACKEND=none anyway.
In this way we simplify the development process, and checking for the
availability of the GUI can be done in run-time through App::isGui()
or Context::isUIAvailable().