mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Fix problem saving transparent GIF and PNG files when the background layer is hidden
This commit is contained in:
parent
e17804e9ff
commit
9fa26dc2f4
@ -535,7 +535,7 @@ bool GifFormat::onSave(FileOp* fop)
|
||||
PixelFormat sprite_format = sprite->pixelFormat();
|
||||
bool interlaced = gif_options->interlaced();
|
||||
int loop = (gif_options->loop() ? 0: -1);
|
||||
bool has_background = (sprite->backgroundLayer() ? true: false);
|
||||
bool has_background = (sprite->backgroundLayer() && sprite->backgroundLayer()->isVisible());
|
||||
int background_color = (sprite_format == IMAGE_INDEXED ? sprite->transparentColor(): 0);
|
||||
int transparent_index = (has_background ? -1: sprite->transparentColor());
|
||||
|
||||
|
@ -414,10 +414,11 @@ bool PngFormat::onSave(FileOp* fop)
|
||||
|
||||
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
|
||||
|
||||
// If the sprite does not have a background layer, we include the
|
||||
// alpha information of palette entries to indicate which is the
|
||||
// transparent color.
|
||||
if (fop->document->sprite()->backgroundLayer() == NULL) {
|
||||
// If the sprite does not have a (visible) background layer, we
|
||||
// include the alpha information of palette entries to indicate
|
||||
// which is the transparent color.
|
||||
if (fop->document->sprite()->backgroundLayer() == NULL ||
|
||||
!fop->document->sprite()->backgroundLayer()->isVisible()) {
|
||||
int mask_entry = fop->document->sprite()->transparentColor();
|
||||
int num_trans = mask_entry+1;
|
||||
png_bytep trans = (png_bytep)png_malloc(png_ptr, num_trans);
|
||||
|
@ -150,8 +150,10 @@ bool Sprite::needAlpha() const
|
||||
{
|
||||
switch (m_format) {
|
||||
case IMAGE_RGB:
|
||||
case IMAGE_GRAYSCALE:
|
||||
return (backgroundLayer() == NULL);
|
||||
case IMAGE_GRAYSCALE: {
|
||||
Layer* bg = backgroundLayer();
|
||||
return (!bg || !bg->isVisible());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user