Merge branch 'master' of git@github.com:aseprite/aseprite.git

This commit is contained in:
David Capello 2015-04-21 14:27:01 -03:00
commit 4b083030f1
4 changed files with 16 additions and 11 deletions

View File

@ -33,13 +33,14 @@ protected:
private: private:
Action m_action; Action m_action;
int m_percentage; render::Zoom m_zoom;
}; };
ZoomCommand::ZoomCommand() ZoomCommand::ZoomCommand()
: Command("Zoom", : Command("Zoom",
"Zoom", "Zoom",
CmdUIOnlyFlag) CmdUIOnlyFlag)
, m_zoom(1, 1)
{ {
} }
@ -52,7 +53,8 @@ void ZoomCommand::onLoadParams(const Params& params)
std::string percentage = params.get("percentage"); std::string percentage = params.get("percentage");
if (!percentage.empty()) { 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; m_action = Set;
} }
} }
@ -74,7 +76,7 @@ void ZoomCommand::onExecute(Context* context)
zoom.out(); zoom.out();
break; break;
case Set: case Set:
zoom = render::Zoom::fromScale(double(m_percentage) / 100.0); zoom = m_zoom;
break; break;
} }
@ -93,7 +95,7 @@ std::string ZoomCommand::onGetFriendlyName() const
text += " out"; text += " out";
break; break;
case Set: case Set:
text += " " + base::convert_to<std::string>(m_percentage) + "%"; text += " " + base::convert_to<std::string>(int(100.0*m_zoom.scale())) + "%";
break; break;
} }

View File

@ -535,7 +535,7 @@ bool GifFormat::onSave(FileOp* fop)
PixelFormat sprite_format = sprite->pixelFormat(); PixelFormat sprite_format = sprite->pixelFormat();
bool interlaced = gif_options->interlaced(); bool interlaced = gif_options->interlaced();
int loop = (gif_options->loop() ? 0: -1); 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 background_color = (sprite_format == IMAGE_INDEXED ? sprite->transparentColor(): 0);
int transparent_index = (has_background ? -1: sprite->transparentColor()); int transparent_index = (has_background ? -1: sprite->transparentColor());

View File

@ -414,10 +414,11 @@ bool PngFormat::onSave(FileOp* fop)
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
// If the sprite does not have a background layer, we include the // If the sprite does not have a (visible) background layer, we
// alpha information of palette entries to indicate which is the // include the alpha information of palette entries to indicate
// transparent color. // which is the transparent color.
if (fop->document->sprite()->backgroundLayer() == NULL) { if (fop->document->sprite()->backgroundLayer() == NULL ||
!fop->document->sprite()->backgroundLayer()->isVisible()) {
int mask_entry = fop->document->sprite()->transparentColor(); int mask_entry = fop->document->sprite()->transparentColor();
int num_trans = mask_entry+1; int num_trans = mask_entry+1;
png_bytep trans = (png_bytep)png_malloc(png_ptr, num_trans); png_bytep trans = (png_bytep)png_malloc(png_ptr, num_trans);

View File

@ -150,8 +150,10 @@ bool Sprite::needAlpha() const
{ {
switch (m_format) { switch (m_format) {
case IMAGE_RGB: case IMAGE_RGB:
case IMAGE_GRAYSCALE: case IMAGE_GRAYSCALE: {
return (backgroundLayer() == NULL); Layer* bg = backgroundLayer();
return (!bg || !bg->isVisible());
}
} }
return false; return false;
} }