From 41e920391817bf29b8fe986c61ba23af49cb48a2 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 4 Nov 2015 11:26:58 -0300 Subject: [PATCH] Fix Edit > Insert Text command for non-RGB sprites --- src/app/commands/cmd_paste_text.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/commands/cmd_paste_text.cpp b/src/app/commands/cmd_paste_text.cpp index e2127d402..c08e74a95 100644 --- a/src/app/commands/cmd_paste_text.cpp +++ b/src/app/commands/cmd_paste_text.cpp @@ -26,6 +26,7 @@ #include "base/unique_ptr.h" #include "doc/image.h" #include "doc/image_ref.h" +#include "render/quantization.h" #include "paste_text.xml.h" @@ -173,6 +174,16 @@ void PasteTextCommand::onExecute(Context* ctx) doc::ImageRef image(render_text(faceName, size, text, color)); if (image) { + Sprite* sprite = editor->sprite(); + if (image->pixelFormat() != sprite->pixelFormat()) { + RgbMap* rgbmap = sprite->rgbMap(editor->frame()); + image.reset( + render::convert_pixel_format( + image.get(), NULL, sprite->pixelFormat(), + DitheringMethod::NONE, rgbmap, sprite->palette(editor->frame()), + false, 0)); + } + editor->pasteImage(image.get()); } }