diff --git a/src/app/commands/cmd_zoom.cpp b/src/app/commands/cmd_zoom.cpp index 9ef7db102..f0e1f1edb 100644 --- a/src/app/commands/cmd_zoom.cpp +++ b/src/app/commands/cmd_zoom.cpp @@ -33,13 +33,14 @@ protected: private: Action m_action; - int m_percentage; + render::Zoom m_zoom; }; ZoomCommand::ZoomCommand() : Command("Zoom", "Zoom", CmdUIOnlyFlag) + , m_zoom(1, 1) { } @@ -52,7 +53,8 @@ void ZoomCommand::onLoadParams(const Params& params) std::string percentage = params.get("percentage"); if (!percentage.empty()) { - m_percentage = std::strtol(percentage.c_str(), NULL, 10); + m_zoom = render::Zoom::fromScale( + std::strtod(percentage.c_str(), NULL) / 100.0); m_action = Set; } } @@ -74,7 +76,7 @@ void ZoomCommand::onExecute(Context* context) zoom.out(); break; case Set: - zoom = render::Zoom::fromScale(double(m_percentage) / 100.0); + zoom = m_zoom; break; } @@ -93,7 +95,7 @@ std::string ZoomCommand::onGetFriendlyName() const text += " out"; break; case Set: - text += " " + base::convert_to(m_percentage) + "%"; + text += " " + base::convert_to(int(100.0*m_zoom.scale())) + "%"; break; } diff --git a/src/app/file/gif_format.cpp b/src/app/file/gif_format.cpp index bff053862..6dfd477b4 100644 --- a/src/app/file/gif_format.cpp +++ b/src/app/file/gif_format.cpp @@ -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()); diff --git a/src/app/file/png_format.cpp b/src/app/file/png_format.cpp index e169057cd..5ebf325b6 100644 --- a/src/app/file/png_format.cpp +++ b/src/app/file/png_format.cpp @@ -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); diff --git a/src/doc/sprite.cpp b/src/doc/sprite.cpp index ce3333946..58f98b5c9 100644 --- a/src/doc/sprite.cpp +++ b/src/doc/sprite.cpp @@ -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; }