mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-30 04:20:23 +00:00
Fix issue merging frames that weren't rendered on any editor at least once
This bug is because the mask color of cel images were fixed when they were used in the rendering process. Now, the mask color is fixed when the image is added to the raster::Stock structure.
This commit is contained in:
parent
47b5a973e9
commit
9dfec919e4
@ -234,7 +234,6 @@ add_library(app-lib
|
||||
undoers/set_sprite_pixel_format.cpp
|
||||
undoers/set_sprite_size.cpp
|
||||
undoers/set_sprite_transparent_color.cpp
|
||||
undoers/set_stock_pixel_format.cpp
|
||||
undoers/set_total_frames.cpp
|
||||
util/autocrop.cpp
|
||||
util/boundary.cpp
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include "app/undoers/set_sprite_pixel_format.h"
|
||||
#include "app/undoers/set_sprite_size.h"
|
||||
#include "app/undoers/set_sprite_transparent_color.h"
|
||||
#include "app/undoers/set_stock_pixel_format.h"
|
||||
#include "app/undoers/set_total_frames.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "raster/algorithm/flip_image.h"
|
||||
@ -161,12 +160,6 @@ void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, Ditherin
|
||||
if (sprite->getPixelFormat() == newFormat)
|
||||
return;
|
||||
|
||||
// Change pixel format of the stock of images.
|
||||
if (undoEnabled())
|
||||
m_undoers->pushUndoer(new undoers::SetStockPixelFormat(getObjects(), sprite->getStock()));
|
||||
|
||||
sprite->getStock()->setPixelFormat(newFormat);
|
||||
|
||||
// TODO Review this, why we use the palette in frame 0?
|
||||
FrameNumber frame(0);
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/undoers/set_stock_pixel_format.h"
|
||||
|
||||
#include "raster/stock.h"
|
||||
#include "undo/objects_container.h"
|
||||
#include "undo/undoers_collector.h"
|
||||
|
||||
namespace app {
|
||||
namespace undoers {
|
||||
|
||||
using namespace raster;
|
||||
using namespace undo;
|
||||
|
||||
SetStockPixelFormat::SetStockPixelFormat(ObjectsContainer* objects, Stock* stock)
|
||||
: m_stockId(objects->addObject(stock))
|
||||
, m_format(stock->getPixelFormat())
|
||||
{
|
||||
}
|
||||
|
||||
void SetStockPixelFormat::dispose()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void SetStockPixelFormat::revert(ObjectsContainer* objects, UndoersCollector* redoers)
|
||||
{
|
||||
Stock* stock = objects->getObjectT<Stock>(m_stockId);
|
||||
|
||||
// Push another SetStockPixelFormat as redoer
|
||||
redoers->pushUndoer(new SetStockPixelFormat(objects, stock));
|
||||
|
||||
stock->setPixelFormat(static_cast<PixelFormat>(m_format));
|
||||
}
|
||||
|
||||
} // namespace undoers
|
||||
} // namespace app
|
@ -1,51 +0,0 @@
|
||||
/* Aseprite
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef APP_UNDOERS_SET_STOCK_PIXEL_FORMAT_H_INCLUDED
|
||||
#define APP_UNDOERS_SET_STOCK_PIXEL_FORMAT_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/undoers/undoer_base.h"
|
||||
#include "undo/object_id.h"
|
||||
|
||||
namespace raster {
|
||||
class Stock;
|
||||
}
|
||||
|
||||
namespace app {
|
||||
namespace undoers {
|
||||
using namespace raster;
|
||||
using namespace undo;
|
||||
|
||||
class SetStockPixelFormat : public UndoerBase {
|
||||
public:
|
||||
SetStockPixelFormat(ObjectsContainer* objects, Stock* stock);
|
||||
|
||||
void dispose() OVERRIDE;
|
||||
size_t getMemSize() const OVERRIDE { return sizeof(*this); }
|
||||
void revert(ObjectsContainer* objects, UndoersCollector* redoers) OVERRIDE;
|
||||
|
||||
private:
|
||||
ObjectId m_stockId;
|
||||
uint32_t m_format;
|
||||
};
|
||||
|
||||
} // namespace undoers
|
||||
} // namespace app
|
||||
|
||||
#endif // UNDOERS_SET_STOCK_PIXEL_FORMAT_H_INCLUDED
|
@ -600,7 +600,7 @@ void RenderEngine::renderLayer(
|
||||
output_opacity = MID(0, cel->getOpacity(), 255);
|
||||
output_opacity = INT_MULT(output_opacity, global_opacity, t);
|
||||
|
||||
src_image->setMaskColor(m_sprite->getTransparentColor());
|
||||
ASSERT(src_image->getMaskColor() == m_sprite->getTransparentColor());
|
||||
|
||||
(*zoomed_func)(image, src_image, m_sprite->getPalette(frame),
|
||||
(cel->getX() << zoom) - source_x,
|
||||
|
@ -325,7 +325,7 @@ void layer_render(const Layer* layer, Image* image, int x, int y, FrameNumber fr
|
||||
src_image = layer->getSprite()->getStock()->getImage(cel->getImage());
|
||||
ASSERT(src_image != NULL);
|
||||
|
||||
src_image->setMaskColor(layer->getSprite()->getTransparentColor());
|
||||
ASSERT(src_image->getMaskColor() == layer->getSprite()->getTransparentColor());
|
||||
|
||||
composite_image(image, src_image,
|
||||
cel->getX() + x,
|
||||
|
@ -50,7 +50,7 @@ Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
|
||||
ASSERT(width > 0 && height > 0);
|
||||
|
||||
m_frlens.push_back(100); // First frame with 100 msecs of duration
|
||||
m_stock = new Stock(format);
|
||||
m_stock = new Stock(this, format);
|
||||
m_folder = new LayerFolder(this);
|
||||
|
||||
// Generate palette
|
||||
@ -136,6 +136,7 @@ void Sprite::setTransparentColor(color_t color)
|
||||
{
|
||||
m_transparentColor = color;
|
||||
|
||||
// Change the mask color of all images.
|
||||
for (int i=0; i<m_stock->size(); i++) {
|
||||
Image* image = m_stock->getImage(i);
|
||||
if (image != NULL)
|
||||
|
@ -23,44 +23,21 @@
|
||||
#include "raster/stock.h"
|
||||
|
||||
#include "raster/image.h"
|
||||
#include "raster/sprite.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace raster {
|
||||
|
||||
Stock::Stock(PixelFormat format)
|
||||
Stock::Stock(Sprite* sprite, PixelFormat format)
|
||||
: Object(OBJECT_STOCK)
|
||||
, m_sprite(sprite)
|
||||
, m_format(format)
|
||||
{
|
||||
// Image with index=0 is always NULL.
|
||||
m_image.push_back(NULL);
|
||||
}
|
||||
|
||||
Stock::Stock(const Stock& stock)
|
||||
: Object(stock)
|
||||
, m_format(stock.getPixelFormat())
|
||||
{
|
||||
try {
|
||||
for (int i=0; i<stock.size(); ++i) {
|
||||
if (!stock.getImage(i))
|
||||
addImage(NULL);
|
||||
else {
|
||||
Image* image_copy = Image::createCopy(stock.getImage(i));
|
||||
addImage(image_copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
for (int i=0; i<size(); ++i) {
|
||||
if (getImage(i))
|
||||
delete getImage(i);
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
ASSERT(size() == stock.size());
|
||||
}
|
||||
|
||||
Stock::~Stock()
|
||||
{
|
||||
for (int i=0; i<size(); ++i) {
|
||||
@ -69,14 +46,9 @@ Stock::~Stock()
|
||||
}
|
||||
}
|
||||
|
||||
PixelFormat Stock::getPixelFormat() const
|
||||
Sprite* Stock::getSprite() const
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void Stock::setPixelFormat(PixelFormat pixelFormat)
|
||||
{
|
||||
m_format = pixelFormat;
|
||||
return m_sprite;
|
||||
}
|
||||
|
||||
Image* Stock::getImage(int index) const
|
||||
@ -97,6 +69,8 @@ int Stock::addImage(Image* image)
|
||||
throw;
|
||||
}
|
||||
m_image[i] = image;
|
||||
|
||||
fixupImage(image);
|
||||
return i;
|
||||
}
|
||||
|
||||
@ -115,6 +89,15 @@ void Stock::replaceImage(int index, Image* image)
|
||||
{
|
||||
ASSERT((index > 0) && (index < size()));
|
||||
m_image[index] = image;
|
||||
|
||||
fixupImage(image);
|
||||
}
|
||||
|
||||
void Stock::fixupImage(Image* image)
|
||||
{
|
||||
// Change the mask color of the added image to the sprite mask color.
|
||||
if (image)
|
||||
image->setMaskColor(m_sprite->getTransparentColor());
|
||||
}
|
||||
|
||||
} // namespace raster
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define RASTER_STOCK_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "base/disable_copying.h"
|
||||
#include "raster/object.h"
|
||||
#include "raster/pixel_format.h"
|
||||
|
||||
@ -28,17 +29,16 @@
|
||||
namespace raster {
|
||||
|
||||
class Image;
|
||||
class Sprite;
|
||||
|
||||
typedef std::vector<Image*> ImagesList;
|
||||
|
||||
class Stock : public Object {
|
||||
public:
|
||||
Stock(PixelFormat format);
|
||||
Stock(const Stock& stock);
|
||||
Stock(Sprite* sprite, PixelFormat format);
|
||||
virtual ~Stock();
|
||||
|
||||
PixelFormat getPixelFormat() const;
|
||||
void setPixelFormat(PixelFormat format);
|
||||
Sprite* getSprite() const;
|
||||
|
||||
// Returns the number of image in the stock.
|
||||
int size() const {
|
||||
@ -66,9 +66,15 @@ namespace raster {
|
||||
//
|
||||
void replaceImage(int index, Image* image);
|
||||
|
||||
//private: TODO uncomment this line
|
||||
private:
|
||||
void fixupImage(Image* image);
|
||||
|
||||
PixelFormat m_format; // Type of images (all images in the stock must be of this type).
|
||||
ImagesList m_image; // The images-array where the images are.
|
||||
Sprite* m_sprite;
|
||||
|
||||
Stock();
|
||||
DISABLE_COPYING(Stock);
|
||||
};
|
||||
|
||||
} // namespace raster
|
||||
|
Loading…
x
Reference in New Issue
Block a user