diff --git a/src/app/commands/cmd_change_pixel_format.cpp b/src/app/commands/cmd_change_pixel_format.cpp index 55a963b23..e157ce7b9 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -9,10 +9,10 @@ #endif #include "app/app.h" +#include "app/cmd/set_pixel_format.h" #include "app/commands/command.h" #include "app/commands/params.h" #include "app/context_access.h" -#include "app/document_api.h" #include "app/modules/editors.h" #include "app/modules/gui.h" #include "app/modules/palettes.h" @@ -367,13 +367,17 @@ void ChangePixelFormatCommand::onExecute(Context* context) m_dithering = window.ditheringAlgorithm(); } + // No conversion needed + if (context->activeDocument()->sprite()->pixelFormat() == m_format) + return; + { ContextWriter writer(context); Transaction transaction(writer.context(), "Color Mode Change"); Document* document(writer.document()); Sprite* sprite(writer.sprite()); - document->getApi(transaction).setPixelFormat(sprite, m_format, m_dithering); + transaction.execute(new cmd::SetPixelFormat(sprite, m_format, m_dithering)); transaction.commit(); } diff --git a/src/app/document_api.cpp b/src/app/document_api.cpp index 0e861a084..abcf2d896 100644 --- a/src/app/document_api.cpp +++ b/src/app/document_api.cpp @@ -37,7 +37,6 @@ #include "app/cmd/set_mask.h" #include "app/cmd/set_mask_position.h" #include "app/cmd/set_palette.h" -#include "app/cmd/set_pixel_format.h" #include "app/cmd/set_slice_key.h" #include "app/cmd/set_sprite_size.h" #include "app/cmd/set_total_frames.h" @@ -55,8 +54,8 @@ #include "doc/frame_tag.h" #include "doc/frame_tags.h" #include "doc/mask.h" +#include "doc/palette.h" #include "doc/slice.h" -#include "render/quantization.h" #include "render/render.h" #include @@ -181,16 +180,6 @@ void DocumentApi::trimSprite(Sprite* sprite) cropSprite(sprite, bounds); } -void DocumentApi::setPixelFormat(Sprite* sprite, - const PixelFormat newFormat, - const render::DitheringAlgorithm dithering) -{ - if (sprite->pixelFormat() == newFormat) - return; - - m_transaction.execute(new cmd::SetPixelFormat(sprite, newFormat, dithering)); -} - void DocumentApi::addFrame(Sprite* sprite, frame_t newFrame) { copyFrame(sprite, newFrame-1, newFrame); diff --git a/src/app/document_api.h b/src/app/document_api.h index e054c1a40..ea199a07e 100644 --- a/src/app/document_api.h +++ b/src/app/document_api.h @@ -12,9 +12,7 @@ #include "doc/color.h" #include "doc/frame.h" #include "doc/image_ref.h" -#include "doc/pixel_format.h" #include "gfx/rect.h" -#include "render/dithering_algorithm.h" namespace doc { class Cel; @@ -46,9 +44,6 @@ namespace app { void setSpriteTransparentColor(Sprite* sprite, color_t maskColor); void cropSprite(Sprite* sprite, const gfx::Rect& bounds); void trimSprite(Sprite* sprite); - void setPixelFormat(Sprite* sprite, - const PixelFormat newFormat, - const render::DitheringAlgorithm dithering); // Frames API void addFrame(Sprite* sprite, frame_t newFrame);