mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-01 09:04:02 +00:00
Fix bug copying cels from Indexed to RGB sprites
This commit is contained in:
parent
8f891a4e25
commit
bdbffc8e6c
@ -369,6 +369,7 @@ add_library(app-lib
|
||||
ui_context.cpp
|
||||
util/autocrop.cpp
|
||||
util/clipboard.cpp
|
||||
util/create_cel_copy.cpp
|
||||
util/expand_cel_canvas.cpp
|
||||
util/filetoks.cpp
|
||||
util/msk_file.cpp
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "app/cmd/set_cel_data.h"
|
||||
#include "app/cmd/unlink_cel.h"
|
||||
#include "app/document.h"
|
||||
#include "app/util/create_cel_copy.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/primitives.h"
|
||||
@ -109,11 +110,12 @@ void CopyCel::onExecute()
|
||||
executeAndAdd(new cmd::RemoveCel(dstCel));
|
||||
|
||||
if (srcCel) {
|
||||
if (createLink)
|
||||
if (createLink) {
|
||||
dstCel = Cel::createLink(srcCel);
|
||||
dstCel->setFrame(m_dstFrame);
|
||||
}
|
||||
else
|
||||
dstCel = Cel::createCopy(srcCel);
|
||||
dstCel->setFrame(m_dstFrame);
|
||||
dstCel = create_cel_copy(srcCel, dstSprite, m_dstFrame);
|
||||
|
||||
executeAndAdd(new cmd::AddCel(dstLayer, dstCel));
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "app/cmd/set_cel_frame.h"
|
||||
#include "app/cmd/unlink_cel.h"
|
||||
#include "app/document.h"
|
||||
#include "app/util/create_cel_copy.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/primitives.h"
|
||||
@ -118,8 +119,7 @@ void MoveCel::onExecute()
|
||||
executeAndAdd(new cmd::SetCelFrame(srcCel, m_dstFrame));
|
||||
}
|
||||
else {
|
||||
dstCel = Cel::createCopy(srcCel);
|
||||
dstCel->setFrame(m_dstFrame);
|
||||
dstCel = create_cel_copy(srcCel, dstSprite, m_dstFrame);
|
||||
|
||||
executeAndAdd(new cmd::AddCel(dstLayer, dstCel));
|
||||
executeAndAdd(new cmd::ClearCel(srcCel));
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "app/file/format_options.h"
|
||||
#include "app/flatten.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/util/create_cel_copy.h"
|
||||
#include "base/memory.h"
|
||||
#include "base/mutex.h"
|
||||
#include "base/scoped_lock.h"
|
||||
@ -364,7 +365,9 @@ void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, La
|
||||
newCel->setFrame(sourceCel->frame());
|
||||
}
|
||||
else {
|
||||
newCel.reset(Cel::createCopy(sourceCel));
|
||||
newCel.reset(create_cel_copy(sourceCel,
|
||||
destLayer->sprite(),
|
||||
sourceCel->frame()));
|
||||
linked.insert(std::make_pair(sourceCel->data()->id(), newCel.get()));
|
||||
}
|
||||
|
||||
|
43
src/app/util/create_cel_copy.cpp
Normal file
43
src/app/util/create_cel_copy.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "render/render.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace doc;
|
||||
|
||||
Cel* create_cel_copy(const Cel* srcCel,
|
||||
const Sprite* dstSprite,
|
||||
const frame_t dstFrame)
|
||||
{
|
||||
base::UniquePtr<Cel> dstCel(
|
||||
new Cel(dstFrame,
|
||||
ImageRef(Image::create(dstSprite->pixelFormat(),
|
||||
srcCel->image()->width(),
|
||||
srcCel->image()->height()))));
|
||||
|
||||
render::composite_image(
|
||||
dstCel->image(), srcCel->image(),
|
||||
srcCel->sprite()->palette(srcCel->frame()), // TODO add dst palette
|
||||
0, 0, 255, BlendMode::SRC);
|
||||
|
||||
dstCel->setPosition(srcCel->position());
|
||||
dstCel->setOpacity(srcCel->opacity());
|
||||
|
||||
return dstCel.release();
|
||||
}
|
||||
|
||||
} // namespace app
|
27
src/app/util/create_cel_copy.h
Normal file
27
src/app/util/create_cel_copy.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
|
||||
#ifndef APP_UTIL_CREATE_CEL_COPY_H_INCLUDED
|
||||
#define APP_UTIL_CREATE_CEL_COPY_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "doc/frame.h"
|
||||
|
||||
namespace doc {
|
||||
class Cel;
|
||||
class Sprite;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
|
||||
Cel* create_cel_copy(const Cel* srcCel,
|
||||
const Sprite* dstSprite,
|
||||
const frame_t dstFrame);
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user