diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp index f24a4371b..1cf2254f4 100644 --- a/src/app/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -1,5 +1,5 @@ /* Aseprite - * Copyright (C) 2001-2013 David Capello + * Copyright (C) 2001-2014 David Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -112,9 +112,16 @@ void CelPropertiesCommand::onExecute(Context* context) if (layer->isBackground()) { slider_opacity->setEnabled(false); tooltipManager->addTooltipFor(slider_opacity, - "The `Background' layer is opaque,\n" - "you can't change its opacity.", - JI_LEFT); + "The `Background' layer is opaque,\n" + "its opacity can't be changed.", + JI_LEFT); + } + else if (sprite->pixelFormat() == IMAGE_INDEXED) { + slider_opacity->setEnabled(false); + tooltipManager->addTooltipFor(slider_opacity, + "Cel opacity of Indexed images\n" + "cannot be changed.", + JI_LEFT); } } else { diff --git a/src/app/document_api.cpp b/src/app/document_api.cpp index 3e8cc2c36..0ceef39da 100644 --- a/src/app/document_api.cpp +++ b/src/app/document_api.cpp @@ -1,5 +1,5 @@ /* Aseprite - * Copyright (C) 2001-2013 David Capello + * Copyright (C) 2001-2014 David Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -195,6 +195,17 @@ void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, Ditherin replaceStockImage(sprite, c, new_image); } + // Set all cels opacity to 100% if we are converting to indexed. + if (newFormat == IMAGE_INDEXED) { + CelList cels; + sprite->getCels(cels); + for (CelIterator it = cels.begin(), end = cels.end(); it != end; ++it) { + Cel* cel = *it; + if (cel->opacity() < 255) + setCelOpacity(sprite, *it, 255); + } + } + // Change sprite's pixel format. if (undoEnabled()) m_undoers->pushUndoer(new undoers::SetSpritePixelFormat(getObjects(), sprite)); @@ -576,6 +587,7 @@ void DocumentApi::setCelPosition(Sprite* sprite, Cel* cel, int x, int y) void DocumentApi::setCelOpacity(Sprite* sprite, Cel* cel, int newOpacity) { ASSERT(cel); + ASSERT(sprite->supportAlpha()); if (undoEnabled()) m_undoers->pushUndoer(new undoers::SetCelOpacity(getObjects(), cel)); diff --git a/src/app/ui/status_bar.cpp b/src/app/ui/status_bar.cpp index a77defafe..5f98a2a76 100644 --- a/src/app/ui/status_bar.cpp +++ b/src/app/ui/status_bar.cpp @@ -1,5 +1,5 @@ /* Aseprite - * Copyright (C) 2001-2013 David Capello + * Copyright (C) 2001-2014 David Capello * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -432,8 +432,10 @@ bool StatusBar::onProcessMessage(Message* msg) updateSubwidgetsVisibility(); const Document* document = UIContext::instance()->activeDocument(); - if (document != NULL) + if (document != NULL) { + updateFromLayer(); updateCurrentFrame(); + } break; } @@ -610,7 +612,9 @@ void StatusBar::updateFromLayer() const Cel* cel; // Opacity layer - if (reader.layer() && + if (reader.sprite() && + reader.sprite()->supportAlpha() && + reader.layer() && reader.layer()->isImage() && !reader.layer()->isBackground() && (cel = reader.cel())) { diff --git a/src/raster/sprite.cpp b/src/raster/sprite.cpp index 47a83ffec..6c1551a87 100644 --- a/src/raster/sprite.cpp +++ b/src/raster/sprite.cpp @@ -174,6 +174,16 @@ bool Sprite::needAlpha() const return false; } +bool Sprite::supportAlpha() const +{ + switch (m_format) { + case IMAGE_RGB: + case IMAGE_GRAYSCALE: + return true; + } + return false; +} + void Sprite::setTransparentColor(color_t color) { m_transparentColor = color; diff --git a/src/raster/sprite.h b/src/raster/sprite.h index f6ce134c2..e537554be 100644 --- a/src/raster/sprite.h +++ b/src/raster/sprite.h @@ -71,6 +71,7 @@ namespace raster { // than 255. Only RGBA and Grayscale images without background needs // alpha channel in the render. bool needAlpha() const; + bool supportAlpha() const; color_t transparentColor() const { return m_transparentColor; } void setTransparentColor(color_t color);