void BackgroundFromLayerCommand::onExecute(Context* context) { ActiveDocumentWriter document(context); Sprite* sprite(document->getSprite()); // each frame of the layer to be converted as `Background' must be // cleared using the selected background color in the color-bar int bgcolor = color_utils::color_for_image(context->getSettings()->getBgColor(), sprite->getImgType()); bgcolor = color_utils::fixup_color_for_background(sprite->getImgType(), bgcolor); { UndoTransaction undo_transaction(document, "Background from Layer"); undo_transaction.backgroundFromLayer(static_cast<LayerImage*>(sprite->getCurrentLayer()), bgcolor); undo_transaction.commit(); } update_screen_for_document(document); }
void BackgroundFromLayerCommand::onExecute(Context* context) { ContextWriter writer(context); Document* document(writer.document()); Sprite* sprite(writer.sprite()); // each frame of the layer to be converted as `Background' must be // cleared using the selected background color in the color-bar int bgcolor = color_utils::color_for_image(context->getSettings()->getBgColor(), sprite->getPixelFormat()); bgcolor = color_utils::fixup_color_for_background(sprite->getPixelFormat(), bgcolor); { UndoTransaction undo_transaction(writer.context(), "Background from Layer"); document->getApi().backgroundFromLayer(static_cast<LayerImage*>(writer.layer()), bgcolor); undo_transaction.commit(); } update_screen_for_document(document); }