Automatically increase the canvas size if bigger images are loaded in a sequence (fix #1719)

This commit is contained in:
David Capello 2018-05-24 15:37:01 -03:00
parent 31dcd3272a
commit 76915c7cb0
2 changed files with 21 additions and 6 deletions

View File

@ -193,16 +193,15 @@ FileOp* FileOp::createLoadDocumentOperation(Context* context, const std::string&
goto done;
}
/* use the "sequence" interface */
// Use the "sequence" interface
if (fop->m_format->support(FILE_SUPPORT_SEQUENCES)) {
/* prepare to load a sequence */
fop->prepareForSequence();
fop->m_seq.flags = flags;
/* per now, we want load just one file */
// At the moment we want load just one file (the one specified in filename)
fop->m_seq.filename_list.push_back(filename);
/* don't load the sequence (just the one file/one frame) */
// If the user wants to load the whole sequence
if (!(flags & FILE_LOAD_SEQUENCE_NONE)) {
std::string left, right;
int c, width, start_from;
@ -572,9 +571,12 @@ void FileOp::operate(IFileOpProgress* progress)
frame_t frames(m_seq.filename_list.size());
frame_t frame(0);
Image* old_image = nullptr;
gfx::Size canvasSize(0, 0);
// TODO setPalette for each frame???
auto add_image = [&]() {
canvasSize |= m_seq.image->size();
m_seq.last_cel->data()->setImage(m_seq.image);
m_seq.layer->addCel(m_seq.last_cel);
@ -657,11 +659,16 @@ void FileOp::operate(IFileOpProgress* progress)
m_filename = *m_seq.filename_list.begin();
// Final setup
if (m_document != NULL) {
if (m_document) {
// Configure the layer as the 'Background'
if (!m_seq.has_alpha)
m_seq.layer->configureAsBackground();
// Set the final canvas size (as the bigger loaded
// frame/image).
m_document->sprite()->setSize(canvasSize.w,
canvasSize.h);
// Set the frames range
m_document->sprite()->setTotalFrames(frame);

View File

@ -1,5 +1,5 @@
// Aseprite Gfx Library
// Copyright (C) 2001-2016 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -91,6 +91,14 @@ public:
return *this;
}
const SizeT& operator|=(const SizeT& sz) {
return *this = createUnion(sz);
}
const SizeT& operator&=(const SizeT& sz) {
return *this = createIntersection(sz);
}
SizeT operator+(const SizeT& sz) const {
return SizeT(w+sz.w, h+sz.h);
}