Remap transparent color when ColorBar "Remap" button is used (fix #677)

This commit is contained in:
David Capello 2015-05-21 09:27:34 -03:00
parent ec26dd7ee9
commit 13ac74f37a

View File

@ -15,6 +15,7 @@
#include "app/app_menus.h" #include "app/app_menus.h"
#include "app/cmd/remap_colors.h" #include "app/cmd/remap_colors.h"
#include "app/cmd/set_palette.h" #include "app/cmd/set_palette.h"
#include "app/cmd/set_transparent_color.h"
#include "app/color.h" #include "app/color.h"
#include "app/commands/command.h" #include "app/commands/command.h"
#include "app/commands/commands.h" #include "app/commands/commands.h"
@ -361,8 +362,16 @@ void ColorBar::onRemapButtonClick()
ContextWriter writer(UIContext::instance(), 500); ContextWriter writer(UIContext::instance(), 500);
Sprite* sprite = writer.sprite(); Sprite* sprite = writer.sprite();
if (sprite) { if (sprite) {
ASSERT(sprite->pixelFormat() == IMAGE_INDEXED);
Transaction transaction(writer.context(), "Remap Colors", ModifyDocument); Transaction transaction(writer.context(), "Remap Colors", ModifyDocument);
transaction.execute(new cmd::RemapColors(sprite, *m_remap)); transaction.execute(new cmd::RemapColors(sprite, *m_remap));
color_t oldTransparent = sprite->transparentColor();
color_t newTransparent = (*m_remap)[oldTransparent];
if (oldTransparent != newTransparent)
transaction.execute(new cmd::SetTransparentColor(sprite, newTransparent));
transaction.commit(); transaction.commit();
} }
update_screen_for_document(writer.document()); update_screen_for_document(writer.document());